Friday, December 24

select option in dropbox through javascript

If you want to select an option in your Dropdown box as you select that option from a link.
Here is solution......

I have used the code with onclick event you r free to use at any event.




Put this into Head section:


<script>
function setdate(num)
{
//alert(num);
document.f1.approxdate[num].selected=true;
}
</script>




Put this into Body section:


<form name="f1" id="f1" >
<select name="selSS1" id="approxdate">
<option value="0">ha ha ha</option>
<option value="1">hi hi hi</option>
<option value="2">hu hu hu</option>
<option value="3">he he he</option>
<option value="4">ho ho ho</option>
</select>
<br /><br />


<a href="javascript:void(0);" onclick="javascript:setdate(0)">ha ha ha</a>
<br />
<a href="javascript:void(0);" onclick="javascript:setdate(1)">hi hi hi</a>
<br />
<a href="javascript:void(0);" onclick="javascript:setdate(2)">hu hu hu</a>
<br />
<a href="javascript:void(0);" onclick="javascript:setdate(3)">he he he</a>
<br />
<a href="javascript:void(0);" onclick="javascript:setdate(4)">ho ho ho</a>
<br />


</form>


     i ♥ i  
Post a Comment