473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

transferring value of radiobutton

<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
2 1845
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
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: VK | last post by:
Hi! What I'm missing in following code? Cannot get the values of radiobuttons. Starting only one class (GetVariant), it works. When I put two classes together, it doesn't. Regards, VK from...
1
by: R.G. Vervoort | last post by:
I would like to make a script wich makes a select visible or not visible depending on what radio button is selected. If the radiobutton with the value "nieuw" is selected the pulldown is not...
1
by: LRW | last post by:
Below is some of the code I'm using. I have a PHP page generating a list of items. I've made it so that each one has a radiobutton with a unique value. You can click on the radiobutton and it will...
1
by: MickG | last post by:
I am trying to change the value of the variable "hard" according to which radio button is pressed and I am having no joy. Could anyone help me with this, the problematic section is marked with...
4
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it...
2
by: Rob | last post by:
Hi all, I've got multiple sets of radio button that are dynamically created in code and populated by a database query. The query returns about 20 recordsets with 3 radio buttons per recordset and...
2
by: Rich | last post by:
Hello, Is it possible to assign a value to a groupbox by selecting a radiobutton contained in the groupbox? Say you assign a value of 1 to radbtn1, 2 for radbtn2, 3 for radbtn3 all contained...
0
by: Nathan Sokalski | last post by:
In the RadioButton and CheckBox controls, there is no Value attribute. The html <inputtag has a value attribute, which is used by both type="radio" and type="checkbox". The RadioButtonList and...
12
by: ive1122 | last post by:
Hi guys, I am looking into create a dynamic survey as posted in Get User Input From Dynamic Controls but with some different environment Below is what i am trying to do: First when the user...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.