Welcome visitor
* Login
* Register
It is currently July 22nd, 2019, 10:33 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Show an input field when radio button is checked only
PostPosted: November 26th, 2009, 8:41 am 

Posts: 23
Hello, I have a form with a radio option and if it is selected then an email address will be requested, otherwise the email thing will never show up. I do already have the radio and the input for the email, I just don't know how to turn it on or off. Any help is highly appreciated, thank you.


Top
 Profile  
 
  Re: Show an input field when radio button is checked only
PostPosted: November 26th, 2009, 9:57 am 
User avatar

Posts: 81
<head>
<style type="text/css">
  .hiddenmail{display:none}
</style>
<script type="text/javascript">
  function validateRadio(){
    if(document.getElementById('radio1').checked==true){
      document.getElementById('mail').disabled=false;
      document.getElementById('mail').style.display='inline';
    }
    else clearForm();
  }
  function clearForm(){
    document.getElementById('mail').style.display='none';
    document.getElementById('mail').disabled=true;
  }
</script>
</head>
<body onload="validateRadio();">
  <form name="form" onreset="clearForm();">
    <input onclick="validateRadio();" type="radio" id="radio1" />
    <label for="radio1">provide email</label>
    <input name="email" disabled="disabled" class="hiddenmail" id="mail" />
    <input type="reset" onclick="validateRadio();" />
  </form>
</body>
:geek:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron