I have a form for a school's helpdesk submissions. Depending on changes (specifically, 3) in the form's data, events occur. The 3 main changes are:
- If a checkbox to specify a room is checked, an input for that room appears
- If one school campus is selected (which it is by default), a select box appears to choose which school
- If "computer" is selected as the problem type (radio button), a select box appears to choose which type of computer
Only the second item above works (school campus --> select box). Both the first and third are dependent upon checkboxes/radio buttons, objects that appear simple to me in JavaScript, but always cause the most trouble.
Here is the javascript, along with corresponding form elements. If you need all of the form's HTML, just let me know. The form name and id are both "new_helpdesk" :
Code:
function panicRoom(){
var ifRoom = document.getElementById('ifRoom');
var chkRoom = document.new_helpdesk.chkRoom;
if(chkRoom.checked){
ifRoom.style.display = 'block';
}
else{
ifRoom.style.display = 'none';
}
}
function clubsideRoad(){
var ifLY = document.getElementById('ifLY');
var campusSel = document.new_helpdesk.campus.value;
if(campusSel == 'LY'){
ifLY.style.display = 'block';
}
else{
ifLY.style.display = 'none';
}
}
function compType(radSel){
var ifComputer = document.getElementById('ifComputer');
if(radSel == true){
ifComputer.style.display = 'block';
}
else{
} ifComputer.style.display = 'none';
}
HTML Code:
<p class="left"><input type="checkbox" name="chkRoom" onclick="panicRoom();" /> Specify Room:</p>
<div id="ifRoom">
<p><input type="text" name="room" /></p>
</div>
HTML Code:
<p class="left"><label for="campus">Campus:</label></p>
<p>
<select name="campus" onchange="clubsideRoad();">
<option value="LY">Lyndhurst</option>
<option value="GM">Gates Mills</option>
<option value="UC">Gries Center</option>
</select>
</p>
<div id="ifLY">
<p class="left"><label for="school">School:</label></p>
<p>
<select name="school">
<option value="lower">Lower</option>
<option value="middle">Middle</option>
<option value="administration">Administration</option>
<option value="other">Other</option>
</select>
</p>
</div>
HTML Code:
<p class="left"><label for="problem_type">Problem Type:</label></p>
<p class="left">
<input type="radio" name="problem_type" value="computer" onclick="compType(true);" /> Computer:<br />
<input type="radio" name="problem_type" value="network logon" onclick="compType(false);" /> Network Logon<br />
<input type="radio" name="problem_type" value="browser filtering" onclick="compType(false);" /> Browser Filtering<br />
<input type="radio" name="problem_type" value="dvd/vhs player" onclick="compType(false);" /> DVD/VHS Player<br />
<input type="radio" name="problem_type" value="computer monitor" onclick="compType(false);" /> Computer Monitor<br />
<input type="radio" name="problem_type" value="projector/smart board" onclick="compType(false);" /> Projector/Smart Board<br />
<input type="radio" name="problem_type" value="lost information" onclick="compType(false);" /> Lost Information<br />
<input type="radio" name="problem_type" value="email" onclick="compType(false);" /> Email<br />
<input type="radio" name="problem_type" value="network connection/wireless" onclick="compType(false);" />Network Connection/Wireless<br />
<input type="radio" name="problem_type" value="printers" onclick="compType(false);" /> Printers<br />
<input type="radio" name="problem_type" value="software request" onclick="compType(false);" /> Software Request
</p>
<div id="ifComputer">
<p class="left"><label for="computer">Computer Type:</label></p>
<p>
<select name="computer">
<option value="desktop">Desktop</option>
<option value="laptop/netbook">Laptop/Netbook</option>
<option value="tablet">Tablet</option>
</select>
</p>
</div>
Note: ID's #ifRoom and #ifComputer are set to display: none in the CSS.
I've checked my syntax over and over, but I can't see anything clearly wrong with it. Any help is appreciated!
Bookmarks