Welcome to WebmasterWorld Guest from 23.22.182.29

Forum Moderators: open

Message Too Old, No Replies

how to set visibility to hidden after the onclick envent handler

     
7:56 am on Apr 25, 2011 (gmt 0)

Full Member

5+ Year Member

joined:Dec 12, 2007
posts:233
votes: 0


Hi,
Someome can help me?

I have this javascript function:

<script type="text/javascript" >
function getSelectedRadio(payment_means){
if(document.getElementById('pay3').checked){
return document.getElementById('chq').style.visibility='visible';
}
else{
return document.getElementById('chq').style.visibility='hidden';
}
}
</script>

I use this function to set visibility of a text box to 'visible' when the third radio button (hereunder) is clicked and to set it back to 'hidden' when i click on another radio button. For the first time i click to the third radio button, it displays the hidden text box and when i click on another radio button, i expected the textbox to disappear but it's not the case. What should I do?

Here is the corresponding html:
<form>
<input type="radio" name="payment_means" value="Cash" id="pay1" />&nbsp;Cash
<input type="radio" name="payment_means" value="Bank Transfer" id="pay2" />&nbsp;Bank Transfert
<input type="radio" name="payment_means" value="Cheque" id="pay3" onClick="getSelectedRadio()" />&nbsp;Cheque
<input type="text" name="chq" value="" id="chq" style="visibility:hidden;" />

</form>


thank you for your kind help
12:55 pm on Apr 25, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 3, 2005
posts:1585
votes: 0


put onClick="getSelectedRadio()" on all 3 input type="radio"
1:56 pm on Apr 25, 2011 (gmt 0)

Full Member

5+ Year Member

joined:Dec 12, 2007
posts:233
votes: 0


Dear daveVk,
1000 thousand thanks. It works now!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members