By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,603 Members | 1,062 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,603 IT Pros & Developers. It's quick & easy.

dynamic list boxes

subashini Thiyagarajan
100+
P: 218
hi,
any one can help me in dynamic list box selection with simple codings.

when the first list box item selected depents on the selected item another list box item should change.
Feb 18 '07 #1
Share this Question
Share on Google+
5 Replies

shweta123
Expert 100+
P: 692
Hi,

here is the sample code

<script language=javascript type="text/javascript">
function f1(selobj)
{
var ind=selobj.selectedIndex;
var selobj1 =document.getElementById("Select2");

selobj1.options.length=0;
if (ind == 0)
{
selobj1.options[selobj1.options.length] = new Option('first choice');
}
if(ind == 1)
{
selobj1.options[selobj1.options.length] = new Option('second choice');
}
}

</script>
</head>


<select id="Select1" style="width: 119px" onchange="f1(this);">
<option selected="selected">One</option>
<option selected="selected">Two</option>
<option selected="selected">Three</option>
</select>
<select id="Select2" style="width: 123px">
</select>

Shweta
Feb 19 '07 #2

subashini Thiyagarajan
100+
P: 218
Shwetha,

thank u so much for your reply.but for me the content is huge i need to retrieve the list box items from a database.can u please help me.i am using access.


as per the first list box second and third list boxes should fill the same content.

pls help me.
Feb 22 '07 #3

subashini Thiyagarajan
100+
P: 218
shwetha,
i have succedeed in my codings i got it.now it is working fine thanks a lot for your initiative.
Feb 22 '07 #4

P: 1
Hi Shweta,

Thanks shweta I was in search for this piece for a long time. Can u help me in sending the same using VB Script instead of Java Script. to my ID bullsb@rediffmail.com

Thanks & Regards,
Badri

Hi,

here is the sample code

<script language=javascript type="text/javascript">
function f1(selobj)
{
var ind=selobj.selectedIndex;
var selobj1 =document.getElementById("Select2");

selobj1.options.length=0;
if (ind == 0)
{
selobj1.options[selobj1.options.length] = new Option('first choice');
}
if(ind == 1)
{
selobj1.options[selobj1.options.length] = new Option('second choice');
}
}

</script>
</head>


<select id="Select1" style="width: 119px" onchange="f1(this);">
<option selected="selected">One</option>
<option selected="selected">Two</option>
<option selected="selected">Three</option>
</select>
<select id="Select2" style="width: 123px">
</select>

Shweta
Feb 23 '07 #5

subashini Thiyagarajan
100+
P: 218
Swetha,

Can u please help me again.the codings which u have send meant for only one item in the list box.i need to populate more items from the database(Access)
can any one pls help me with the simple codings

thanks
Mar 6 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.