By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

transferring value of radiobutton

P: n/a
<form name=form1>
Load in Viewer Window:
<input name="radiobutton" type="radio" value="1" checked onClick="1">
1&nbsp;&nbsp;&nbsp;
<input type="radio" name="radiobutton" value="2" onClick="2">
2&nbsp;&nbsp;&nbsp;
<input type="radio" name="radiobutton" value="3" onClick="3">
3&nbsp;&nbsp;&nbsp;
<input type="radio" name="radiobutton" value="4" onClick="4">
4
<input type=file name="fileN" size="75" >
<br>
<input type=submit onClick="setFileMul(document.form1.radiobutton.val ue)"
value="Load Selected File">
<font size="3"><strong>Choose/Browse for sutiable Chime file
above</strong></font>
</form>

I am trying to get setFileMul( ) to pick which number radiobutton has been
checked. If I put a number such as setFileMul(2), the function works fine. What
do I need to put which radiobutton number has been checked in setFileMul(_)?

I though document.form1.radiobutton.value would have done the job.

Thanks,
Jeff

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 11 Feb 2004 18:51:25 GMT, JeffFinnan <je********@aol.com> wrote:
I am trying to get setFileMul( ) to pick which number radiobutton has
been checked. If I put a number such as setFileMul(2), the function
works fine. What do I need to put which radiobutton number has been
checked in setFileMul(_)?

I though document.form1.radiobutton.value would have done the job.


Almost: document.form1.radiobutton will return a collection of all form
controls with the name "radiobutton", not the currently selected element.
Try:

<input type="submit" value="Load Selected File"
onClick="setFileMul(getOrdinal(this.form.radiobutt on))">
...
function getOrdinal( buttonGroup ) {
var groupSize = buttonGroup.length;

for( var i = 0; i < groupSize; ++i ) {
if( buttonGroup[ i ].checked ) return buttonGroup[ i ].value;
}
}

Be aware that the function above, getOrdinal, returns a string, not a
number (the value attribute is of type string).

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

P: n/a
>Try:

<input type="submit" value="Load Selected File"
onClick="setFileMul(getOrdinal(this.form.radiobutt on))">
...
function getOrdinal( buttonGroup ) {
var groupSize = buttonGroup.length;

for( var i = 0; i < groupSize; ++i ) {
if( buttonGroup[ i ].checked ) return buttonGroup[ i ].value;
}
}

Be aware that the function above, getOrdinal, returns a string, not a
number (the value attribute is of type string).


==============
Mike,

That did the trick. It did not seem to matter whether it was string or not.

Thanks much,
Jeff
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.