View Full Version : javascript dropdown list to show by default selected value

01-28-2011, 07:53 PM
Can someone tell me the code to display dropdown box showing a default value as selected which can vary as per the user’s condition using script..i,e by enclosing in document.write..
Now i need to print a for loop counter variable's value as the default selected option if a condition satisfies..

<script type="text/javascript">
document.write("<SELECT NAME=\"choice\" >")
for (var counter=0; counter<10;counter++)
{<!—what should be the code here to display 6 as by default selected option-->
{ <!-- what should be the code here to display the counter value other than 6 as an option in the dropdown box-->