|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Reset SELECT...
I have a JavaScript function that resets a couple of items in my form. It currently resets an input and textarea.
I was wondering how do I make it reset a SELECT. Current code as follows: php Code:
items is the SELECT I would like to have RESET to show SELECTEDINDEX number 1. Any help would be greatly appreciated. |
|
#2
|
|||
|
|||
|
RE: Reset SELECT...
I believe you can just set the value of the select field to the value you want... you'd have to use the value, though... what does the form look like?
instead of: would work? -Jeff |
|
#3
|
|||
|
|||
|
RE: Reset SELECT...
Sorry, no good. It simply goes empties the selected item. it doesn't go back to the first item.
|
|
#4
|
|||
|
|||
|
RE: Reset SELECT...
What does the form look like... for example, the following code will change the drop-down above from Client Side Things to Database Help... you need to ensure that you have the correct value...
Code:
javascript:document.forms[3].forum.value='sqlhelp';void(0); if you are using IE, hit CTRL+O, paste that into the field and hit enter... it should change the value of the select. I am pretty sure something similar works with Mozilla as well. -Jeff |
|
#5
|
|||||||||||
|
|||||||||||
|
RE: Reset SELECT...
The select for the form looks like this:
php Code:
When the checkbox is selected, Code as follows: php Code:
I need to reset the list from whatever option was selected to the first one, the one that currently says: The code that does the reset is as follows: php Code:
To recap, I need the above function to disable the select and set it back to the default state, which has the first item listed shown. |
|
#6
|
|||
|
|||
|
RE: Reset SELECT...
I think this is what you're after?
Code:
onclick="document.rush_1200.items.selectedIndex=1;" [edit]actually 0(zero) if you want the first item[/edit] |
|
#7
|
|||
|
|||
|
RE: Reset SELECT...
None of your options have values associated with them. If you want the value to equal the displayed text, the form should look something like this:
Code:
<select class="selectbox" name="items"> <option value='CLICK HERE'>CLICK HERE</option> <option value='N245620'>N245620</option> <option value='N354569'>N354569</option> <option value='N555780'>N555780</option> <option value='O890761'>O890761</option> <option value='P874657'>P874657</option> <option value='NOT LISTED'>NOT LISTED</option> </select> Alternatively to have a number associated with each: Code:
<select class="selectbox" name="items"> <option value='0'>CLICK HERE</option> <option value='1'>N245620</option> <option value='2'>N354569</option> <option value='3'>N555780</option> <option value='4'>O890761</option> <option value='5'>P874657</option> <option value='6'>NOT LISTED</option> </select> Then the suggestion... Code:
onclick="document.rush_1200.items.value='CLICK HERE';" or Code:
onclick="document.rush_1200.items.value='0';" (respectively) should work. -Jeff |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Reset SELECT... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|