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

force one radio button to take a value from another one

Hello,

I am a complete JS newbie. I am trying to make one radio button assume
a certain value when another one in a different group is clicked. This
is a conference registration form for which most applicants will pay,
but some do not. It is passing form data to a ColdFusion backend, and
I simply wish to have
the non-paying applicants have the no-pay "payment type" automatically
selected
when they select the no-pay registration type. I have tried the
following with no success (in IE 6.0; I want to test it here first)

<script language="JavaScript" TYPE="text/javascript">

function forceCompPay() {

if (document.forms[1].groupType == "speaker") {
document.forms[1].groupPayment[comp].checked = true

}
}
</script>
</head>

the "master" button is:
<cfinput type="radio" name="type" value="speaker"
onClick="forceCompPay()">Speaker

the "slave" button is :

<cfinput type="radio" name="payment" value="comp">&nbsp;Comp

everyone else would need to manually select the other payment types.
Any input would be vastly appreciated.

Ed
Jul 20 '05 #1
2 4936
ed a wrote on 21 Nov 2003:
<script language="JavaScript" TYPE="text/javascript">
The language attribute isn't necessary.
function forceCompPay() {

if (document.forms[1].groupType == "speaker") {
document.forms[1].groupPayment[comp].checked = true
}
}


First, a few assumptions:

The name of the form is "register".*
The name of the delegate type radio buttons is "type".
The name of the payment type radio buttons is "payment".
The "speaker" delegate type is the first (index 0) button in "type".
The "no payment" payment type is the third (index 2) button in
"payment".

// If "speaker" is selected...
if (document.forms['register'].elements['type'][0].checked)
{
// ...set the payment type to "no payment"
document.forms['register'].elements['payment'][2].checked = true;
}

All you need to do is change the form name, radio button group names,
and the button indicies**.

Hope that helps.

Mike
* Using the form name is better than an index (easier maintenance).
** Despite the note above, you have no choice but to use the index.

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #2
It certainly did. Now I can put back all the hair I pulled out ;-)

Thanks a million!

Ed

Michael Winter <M.******@blueyonder.co.uk.invalid> wrote in message news:<Xn*******************************@193.38.113 .46>...
ed a wrote on 21 Nov 2003:
<script language="JavaScript" TYPE="text/javascript">


The language attribute isn't necessary.
function forceCompPay() {

if (document.forms[1].groupType == "speaker") {
document.forms[1].groupPayment[comp].checked = true
}
}


First, a few assumptions:

The name of the form is "register".*
The name of the delegate type radio buttons is "type".
The name of the payment type radio buttons is "payment".
The "speaker" delegate type is the first (index 0) button in "type".
The "no payment" payment type is the third (index 2) button in
"payment".

// If "speaker" is selected...
if (document.forms['register'].elements['type'][0].checked)
{
// ...set the payment type to "no payment"
document.forms['register'].elements['payment'][2].checked = true;
}

All you need to do is change the form name, radio button group names,
and the button indicies**.

Hope that helps.

Mike
* Using the form name is better than an index (easier maintenance).
** Despite the note above, you have no choice but to use the index.

Jul 20 '05 #3

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

Similar topics

1
by: David | last post by:
Hi, I have an ASP page with a form and the following code: ..... type=Radio Checked name=selectserial value=" & RS("PSL_F_Serial")..... Tis will carry over the value of RS("PSL_F_Serial"),...
3
by: ewitkop90 | last post by:
Here is my code: <SCRIPT> function transportchange(transport) { if (framenewinstall.Helpdesk.checked) framenewinstall.Helpdesk.checked=false; if (framenewinstall.CircuitNumber.checked)...
3
by: Karl | last post by:
Hi experts, In my application, I have a employee table containing a gender field which has value "M", "F". I bind gender field to the "checked" property of a group of 2 radio buttons. I hope to...
33
by: Brian | last post by:
I have a list of plain HTML radio buttons that I want to be able to loop through, get the values from them and insert them into a db. each one should be a separate record... Can anyone please give...
8
by: David Cameron | last post by:
I noticed that using an HTMLInputRadioButton and specifying a value to be an empty string (""), this is overridden by ASP.Net which set the value of the control to be the same as the ID of the...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
1
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
11
by: Twayne | last post by:
Hi, Newbie to PHP here, no C or other relevant background, so pretty niave w/r to the nuances etc. but I think this is pretty basic. XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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:
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.