473,395 Members | 1,571 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,395 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 11907
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.