I have two radio buttons and one Listbox.I wanna do, If i select radio buttonOne then According to that radio button ,listBox values have to be loaded.If i checked other radio button, According to that radio button ,Different listBox values have to be loaded.
Bref:
if select RadioButtonOne
ListBoxOne values shuld be =>> (a,b,c,d,e);
if select RadioButtonTwo
ListBoxOne values shuld be =>> (1,2,3,4,5,6,7,8,9);
rememmber: I have two radio buttons and Only one ListBox
Thank you forum..!!!
How to add values to ListBox?
Moderator: General Moderators
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: How to add values to ListBox?
json/ajax anyone of them will work for you.
Re: How to add values to ListBox?
No need of AJAX in this case. And using jQuery would be an overkill.novice4eva wrote:json/ajax anyone of them will work for you.
Just use the DOM and a little of Javascript.
There are 10 types of people in this world, those who understand binary and those who don't
- pavanpuligandla
- Forum Contributor
- Posts: 130
- Joined: Thu Feb 07, 2008 8:25 am
- Location: Hyderabad, India
Re: How to add values to ListBox?
hiya..
no need of ajax or javascript.
u can do that using php itself, firstly hide both the listboxes, then if user clicks radio1, then include list1 else list2
<form action="test.php">
in test.php write code for radio button click(only 1 button shld b clicked at a time)
then
if{radio1(true);
list1}
else{list2}
make sure which list box has to appear if radio1 is clicked. no need to write the condition for radio2, bcoz u r usin only 2 radio buttons..
if u use more than 2 then use switch.
no need of ajax or javascript.
u can do that using php itself, firstly hide both the listboxes, then if user clicks radio1, then include list1 else list2
<form action="test.php">
in test.php write code for radio button click(only 1 button shld b clicked at a time)
then
if{radio1(true);
list1}
else{list2}
make sure which list box has to appear if radio1 is clicked. no need to write the condition for radio2, bcoz u r usin only 2 radio buttons..
if u use more than 2 then use switch.
Re: How to add values to ListBox?
There are a number of ways to do this depending on what your requirements are. Are you pulling the listbox data from a database or is it predefined data that is hardcoded in the JS? If its hardcoded in the HTML you can use two spans and just have javascript toggle the style display to choose which is showing, if its hardcoded into the JS, you can write a function to fill the listbox data in. If you are looking to pull it from a server, you can use AJAX or a number of other methods to pull the data on the fly.