PDA

View Full Version : Radios...checkboxes


Tails
01-02-2003, 04:17 PM
I have a problem. I learned a little on how to use checkboxes, but radio buttons are not working the same way. All I know is that radio buttons can share names in a set and only one can be clicked. But I'm unable to read an accurate value from the INPUT. It's always the first one regardless of what box is checked.

piz
01-02-2003, 04:22 PM
Could you give us your code please?
so we can see how you did it.
thx.
piz

joeframbach
01-02-2003, 04:28 PM
so... is your problem regarding radios or checkboxes?

Tails
01-02-2003, 05:07 PM
Here it is uploaded as a zip. And is it just me or does this page take forever to load on an offline computer? I really need some code cleanup. Incase you are wondering, there's so much stuff in the onLoad since IE chooses to keep selections where you left it when you reload the page and I had to get the images in sync each reload.

piz
01-02-2003, 05:13 PM
Sorry - but i won't read all this code...
i'm damned lazy...

couldn't you sent me the function or the code where the error appears?

Tails
01-02-2003, 05:22 PM
Well, there's no error to speak of. Problem is I just don't know how to set up a radio button. But here's an example:

<FORM name="G">
<INPUT type="radio" name="green" value="0" selected>None<BR>
<INPUT type="radio" name="green" value="1">Some<P>
<INPUT type="button" value="try to get value" onClick="alert(G.green.value)">
<INPUT type="button" value="try to get checked status" onClick="alert(G.green.checked)">
</FORM>

I probably have the wrong idea altogether, so correct me please.

piz
01-02-2003, 05:34 PM
Ouh you can't do that this way.
You have two elements called "green", now you want to see the value of the element with G.green.value.

But th compiler doesn't know what element you mean - for him, "green" is an array with various values. You have to use indexes:

<FORM name="G">
<INPUT type="radio" name="green" value="0" selected>None<BR>
<INPUT type="radio" name="green" value="1">Some<P>
<INPUT type="button" value="try to get checked status" onClick="alert(G.green[0].checked)">
</FORM>

Tails
01-02-2003, 05:43 PM
Oh, is that all? That's simple. Indexes are my best friend. Especially for compression reasons. For example, look in that edit.zip and search for: function num() I like to use indexes in FOR loops.