473,378 Members | 1,140 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,378 software developers and data experts.

radio box value is always undefined ?

I was working on this simple form with radio boxes.
And when I click on one of the radio box, it tell me the value is
"undefined"
Why is that ? I did defined the value of each radio box:

<input type=radio name='Usetax' value='basic'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='no'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='mytax'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>

Can anyone help ?

Thank a lot.

Eric
Here is the entire HTML:

<html>
<body>
<form name='myform' action='post'>
<input type=radio name='Usetax' value='basic'
onClick="document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">

Default Tax

<input type=radio name='Usetax' value='no' checked
onClick="document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">

No Tax

<input type=radio name='Usetax' value='mytax'
onClick="
document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">
Other tax
<br>
Tax Amount: $<input type=text name=tax size=5 value=0.00><br>
total amount
<input type=text name=amount value="">
</form>

</body></html>
--

Jul 20 '05 #1
3 11901
Eric,

Try this:-

<form name="myform">
<input type=radio name="Usetax" value="basic"
onClick="document.myform.amount.value=this.value;" >
<input type=radio name="Usetax" value="no"
onClick="document.myform.amount.value=this.value;" >
<input type=radio name="Usetax" value="mytax"
onClick="document.myform.amount.value=this.value;" >
<input type="text" name="amount">
</form>

Stu
"Eric Chang" <ec****@eatools.com> wrote in message
news:c8*******************@twister.socal.rr.com...
I was working on this simple form with radio boxes.
And when I click on one of the radio box, it tell me the value is
"undefined"
Why is that ? I did defined the value of each radio box:

<input type=radio name='Usetax' value='basic'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='no'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='mytax'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>

Can anyone help ?

Thank a lot.

Eric
Here is the entire HTML:

<html>
<body>
<form name='myform' action='post'>
<input type=radio name='Usetax' value='basic'
onClick="document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">

Default Tax

<input type=radio name='Usetax' value='no' checked
onClick="document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">

No Tax

<input type=radio name='Usetax' value='mytax'
onClick="
document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">
Other tax
<br>
Tax Amount: $<input type=text name=tax size=5 value=0.00><br>
total amount
<input type=text name=amount value="">
</form>

</body></html>
--

Jul 20 '05 #2
"Eric Chang" <ec****@eatools.com> wrote in message news:<c8*******************@twister.socal.rr.com>. ..
I was working on this simple form with radio boxes.
And when I click on one of the radio box, it tell me the value is
"undefined"
Why is that ? I did defined the value of each radio box:

<input type=radio name='Usetax' value='basic'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='no'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='mytax'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>

Can anyone help ?

Thank a lot.

Eric


Hi

I think in the code you should use above in each of the 3 radio
buttons is:

onClick='document.myform.amount.value=this.value'

which will put the string 'basic', 'no' or 'mytax' into the amount
form element (assuming they're the values what you want in amount).

I think document.myform.Usetax doesn't have value because...
document.myform.Usetax is an array of the elements that share the name
'Usetax' so it is 3 radio buttons with 3 values:
document.myform.Usetax[0].value which is 'basic'
document.myform.Usetax[1].value which is 'no'
document.myform.Usetax[3].value which is 'mytax'
but it's nicer to use 'this.value' to get the value of the radio
button clicked.

Hope that helps.

Mark
Jul 20 '05 #3
"Eric Chang" <ec****@eatools.com> wrote in message news:<c8*******************@twister.socal.rr.com>. ..
I was working on this simple form with radio boxes.
And when I click on one of the radio box, it tell me the value is
"undefined"
Why is that ? I did defined the value of each radio box:

<input type=radio name='Usetax' value='basic'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='no'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>
<input type=radio name='Usetax' value='mytax'
onClick='document.myform.amount.value=document.myf orm.Usetax.value'>

Can anyone help ?

Thank a lot.

Eric
Here is the entire HTML:

<html>
<body>
<form name='myform' action='post'>
<input type=radio name='Usetax' value='basic'
onClick="document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">

Default Tax

<input type=radio name='Usetax' value='no' checked
onClick="document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">

No Tax

<input type=radio name='Usetax' value='mytax'
onClick="
document.forms[0].amount.value=document.myform.Usetax.value;
return(true);">
Other tax
<br>
Tax Amount: $<input type=text name=tax size=5 value=0.00><br>
total amount
<input type=text name=amount value="">
</form>

</body></html>
--

value defines the NAME of a variable that is either true (button
checked) or false (button not checked).
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bbxrider | last post by:
i have 2 radio buttons 1 for yes and 1 for no, it is mandatory for one to be checked, and am purposely leaving both blank on the page when i tested for .value, when neither was checked, an alert...
6
by: amith | last post by:
hi, i have some 10 radio buttons meant to take the rating from the user. ex: 1 2 3 4 5 6 7 8 9 10 looks O O O O O O O O O O 1 2 3 4 5 6 7 8 9 10 features O O O O O O O O O O
15
by: tabonni | last post by:
I want to check each button groups and save the checked value into a 2 dimensional array. But, it doesn't work. Could anyone tell me what's wrong with my code. My code is as follow: <html>...
2
by: jason | last post by:
The following (likely far from imperfect code), reports a value of NaN in the j4 display. I suppose the problem is I am not really passing the "checked" value of the radio button via .value ......
8
by: wl | last post by:
Hi, I have a radiobutton group in HTML in a form: Sex: <input type="radio" name="Sex" value="male">Male <input type="radio" name="Sex" value="female">Female <input type="radio" name="Sex"...
22
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I...
4
by: Pasquale | last post by:
I am using the JS and HTML code below to check that required fields are completed for attributes of a product. The first attribute is a select menu and the second is a radio set. My JS goes through...
2
by: runway27 | last post by:
i am using a self submitting form <form action="<?php echo $_SERVER; ?>" method="POST" id="test2" name="test1"> i need to do a validation of textfields, checkboxes, radio buttons i am able...
3
Uncle Dickie
by: Uncle Dickie | last post by:
Hi All, I am trying to extract some data from a 2D array based on a radio button and drop down combination. I have the following code but I am not getting a value for the radio button object so...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.