467,892 Members | 1,920 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,892 developers. It's quick & easy.

On select Radio Button / Change Combo box values

Hi,

I have a radio button and a combo box.

Upon changing a value for radio button, the combo box values will be
dynamically updated.

I have an idea on how to go abt doing it but Im stuck into converting into
code.

Eg: I will have 3 arrays. arr1, arr2, arr3.

Each array contains the values that is to be in the combo box.

I have 3 radio buttons. r1,r2,r3

I have one combo box, combo1.

Upon clicking r1, combo1's option value will be changed to values of arr1,
etc etc

Please advise. Thanks

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Dec 30 '06 #1
  • viewed: 12002
Share:
2 Replies
Eric Layman wrote on 31 dec 2006 in comp.lang.javascript:
I have a radio button and a combo box.
"A combo box is a user interface control GUI element. It is a combination
of a drop-down list or list box and a single-line textbox, allowing the
user to either: 1) type a value directly into the control; or 2) choose
from the list of existing options."
<http://en.wikipedia.org/wiki/Combo_box>

That does not exist in HTML, but probably you mean a drop-down list.
Upon changing a value for radio button, the combo box values will be
dynamically updated.

I have an idea on how to go abt doing it but Im stuck into converting
into code.
Well, show your code sofar.
Eg: I will have 3 arrays. arr1, arr2, arr3.
Each array contains the values that is to be in the combo box.
I have 3 radio buttons. r1,r2,r3
I have one combo box, combo1.

Upon clicking r1, combo1's option value will be changed to values of
arr1, etc etc

Please advise. Thanks
It seems you want us to do the javascript coding?
Perhaps you better hire a professional programmer?

Better start programming yourself, this will educate nxt to the getting
of the desired result.

Some help perhaps:

You could start leaving the idea of the arrays and
just build 3 different drop-down lists, of which only one is displayed at
a time, the other two are CSS-display:none;-ed by the radio button
settings.

This will prevent the need of complex DOM child adding and removing.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 30 '06 #2
Eric Layman wrote:
I have a radio button and a combo box.
Upon changing a value for radio button, the combo box values will be
dynamically updated.
I have an idea on how to go abt doing it but Im stuck into converting into
code.
Eg: I will have 3 arrays. arr1, arr2, arr3.
Each array contains the values that is to be in the combo box.
I have 3 radio buttons. r1,r2,r3
I have one combo box, combo1.
Upon clicking r1, combo1's option value will be changed to values of arr1,
etc etc
var cars = new Array('Audi','BMW','Ford','Opel','Toyota');
var days = new Array('Monday','Wednesday','Friday');
var jobs = new Array('engineer','salesman');

document.write('<form>'
+'<input type="radio" name="r" value="r1" onClick="p1(cars)">cars'
+'<input type="radio" name="r" value="r2" onClick="p1(days)">days'
+'<input type="radio" name="r" value="r3" onClick="p1(jobs)">jobs'
+'<hr><select size="1" name="combo1" style="width:150px">'
+'<option value="">choose radio</option>'
+'</select>'+'</form>');

var co = document.forms[0].combo1;

function p1(nC) {
while (co.options.length) co.options[0] = null;
for (var i = 0; i < nC.length; i++)
co.options[co.length] = new Option(nC[i], nC[i]);
}

Hope this helps,

--
Bart

Dec 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Steve Chatham | last post: by
2 posts views Thread by sejal17 | last post: by
1 post views Thread by Izzy123 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.