Forum Moderators: open

Message Too Old, No Replies

Help with radiobuttons, checkboxes and select items

         

aguzman

2:03 pm on Feb 22, 2006 (gmt 0)

10+ Year Member



Hi,

How can I set a "default selected" item in a group of raidobuttons, checkboxes and/or select group?

The question is because when I write the code I can tell which element is "selected" or "checked" but if I change it manually on the website and I reload the page, the suppossed "selected" value in the first place isn't selected but the new selected value remains.
Is there any way to define a "default selected" value for this items (radiobutton, checkboxes and select)?

Thank you!

Ale

Kufu

5:30 pm on Feb 22, 2006 (gmt 0)

10+ Year Member



for a check box and radio button simply put in 'checked' for the selection you'd like to be the default. And for a drop-down list put in 'selected'

<input type="radio" checked>
<input type="checkbox" checked>.

drop-down:
<option selected>Example</option>

aguzman

6:06 pm on Feb 22, 2006 (gmt 0)

10+ Year Member



Mmm it seems I didn't explain my self very clear. Thank you anyway.
I'll try to explain in a better way my problem.

Ok, for radiobuttons and checkboxes I just have to put "checked" as an attribute.
And for a drop-down list I just have to put "selected".
I do that...

Imagin a drop down list like this one:

<select>
<option selected="selected">1st Option</option>
<option>2nd Option</option>
<option>3rd Option</option>
</selected>

When I load the page the selected item is "1st Option". Then I select "3rd Option" with the mouse(on the webpage, the code remains just like the one above).
The problem is that when I reload the page (pressing F5 or clicking the Reload button on the browser), the selected item is "3rd Option" and no "1st Option" like the code says. The only way I can get the original webpage is to load the page all over again, and for my work right now that is no good.
This happend in FF(Linux/Windows) and IE.
Is there anyway to fix that?
I hope now the question is more clear.

Thank you!

jalarie

2:23 pm on Feb 24, 2006 (gmt 0)

10+ Year Member



How about the following in the body tag:

onload="document.forms[0].reset();"