Jordan656
04-05-2009, 07:24 PM
Hi
Im using the following script to toggle a div in a form
function toggleMe2(obj, a){
var e=document.getElementById(a);
if(!e)return true;
e.style.display="inline"
return true;
}
function toggleMe(obj, a){
var e=document.getElementById(a);
if(!e)return true;
e.style.display="none"
return true;
}
and the form code:
<p>New title:
<select name="new_title">
<option value="" selected="selected">Select your new title</option>
<option value="Mr" onclick="return toggleMe(this, 'othernewtitle')">Mr</option>
<option value="Mrs" onclick="return toggleMe(this, 'othernewtitle')">Mrs</option>
<option value="Miss" onclick="return toggleMe(this, 'othernewtitle')">Miss</option>
<option value="Ms" onclick="return toggleMe(this, 'othernewtitle')">Ms</option>
<option value="Dr." onclick="return toggleMe2(this, 'othernewtitle')">Dr.</option>
<option value="Rev." onclick="return toggleMe(this, 'othernewtitle')">Rev.</option>
<option value="Prof." onclick="return toggleMe(this, 'othernewtitle')">Prof.</option>
</select>
<div id="othernewtitle" style="display: none;">
doctor / dentists ref<input name="gmcgdcno" type="text" />
</div>
I need to add another form element, 'Other'. I need to have another div toggled on when it is clicked, and toggled off when anything else is clicked. I tried having 2 onclick commands, but that didnt work (i didnt think it would - but gave it a shot anyway). Anyone know how to get this to work?
Im using the following script to toggle a div in a form
function toggleMe2(obj, a){
var e=document.getElementById(a);
if(!e)return true;
e.style.display="inline"
return true;
}
function toggleMe(obj, a){
var e=document.getElementById(a);
if(!e)return true;
e.style.display="none"
return true;
}
and the form code:
<p>New title:
<select name="new_title">
<option value="" selected="selected">Select your new title</option>
<option value="Mr" onclick="return toggleMe(this, 'othernewtitle')">Mr</option>
<option value="Mrs" onclick="return toggleMe(this, 'othernewtitle')">Mrs</option>
<option value="Miss" onclick="return toggleMe(this, 'othernewtitle')">Miss</option>
<option value="Ms" onclick="return toggleMe(this, 'othernewtitle')">Ms</option>
<option value="Dr." onclick="return toggleMe2(this, 'othernewtitle')">Dr.</option>
<option value="Rev." onclick="return toggleMe(this, 'othernewtitle')">Rev.</option>
<option value="Prof." onclick="return toggleMe(this, 'othernewtitle')">Prof.</option>
</select>
<div id="othernewtitle" style="display: none;">
doctor / dentists ref<input name="gmcgdcno" type="text" />
</div>
I need to add another form element, 'Other'. I need to have another div toggled on when it is clicked, and toggled off when anything else is clicked. I tried having 2 onclick commands, but that didnt work (i didnt think it would - but gave it a shot anyway). Anyone know how to get this to work?