-
javascript dropdown list to show by default selected value
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..
<CODE>
<script type="text/javascript">
document.write("<SELECT NAME=\"choice\" >")
for (var counter=0; counter<10;counter++)
{
if(counter==6)
{<!—what should be the code here to display 6 as by default selected option-->
}
else
{ <!-- what should be the code here to display the counter value other than 6 as an option in the dropdown box-->
}
}
document.write("</SELECT>");
</scriPT>
</CODE>
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks