Translate

Monday 3 June 2013

Click Other field in an Select Option by using Javascript

Live Demo:


College:

index.php:

<form name="arun" id="checkid">
<div align="center" id="tbl">
<span style="font-size:18px;">College:</span>
<select name="country" onchange="ShowTB(this,'click');" id="on">
<option id="count">-------select-------</option>
<option id="count">South America</option>
<option id="count">North America</option>
<option id="count">Africa</option>
<option id="count">London</option>
<option id="count">other</option></select><br /><br />
<input type="text" id="click" placeholder="Please Enter The College Name" style="visibility:hidden; margin-right:-170px; width:45%;" />
</div> 
</form>

Script.php:
<script language="JavaScript" type="text/javascript">

function ShowTB(obj,id){
 txt=obj.options[obj.selectedIndex].text;
 if (txt.match('select')){
  document.getElementById(id).style.visibility='hidden';
 }
 if (txt.match('other')){
  document.getElementById(id).style.visibility='visible';
 }
}

</script>

No comments:

Post a Comment