Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / December 2006



Tip: Looking for answers? Try searching our database.

On select Radio Button / Change Combo box values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric Layman - 30 Dec 2006 15:50 GMT
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
Evertjan. - 30 Dec 2006 16:11 GMT
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.
[quoted text clipped - 5 lines]
>
> 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.

Signature

Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Bart Van der Donck - 31 Dec 2006 12:51 GMT
> I have a radio button and a combo box.
> Upon changing a value for radio button, the combo box values will be
[quoted text clipped - 7 lines]
> 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,

Signature

Bart

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.