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

value of Drop Down

P: 14
Hi,
I have two dropdowns. In first dropdown i have two languages say english, persian. When i select english in 2nd dropdown iam able to show list of english movies. Problem is i need first dropdown selected value to use for second dropdown onchange. How can i use first dropdown value for second one?.

this is select box code for second dropdown

<select id="Moviename" name="Moviename" onChange="showCustomer(lan)">

Here lan is language that selected in first dropdown. How can i get that lan value to here???.

Please Help.
Jan 20 '07 #1
Share this Question
Share on Google+
10 Replies

acoder
Expert Mod 15k+
P: 16,027
If your code for 1st dropdown is
[HTML]<select id="Language" name="Language">[/HTML]
then the following code
Expand|Select|Wrap|Line Numbers
  1. var sel = document.getElementById("Language");
  2. var lan = sel.options[sel.selectedIndex].text;
will give you the value you require. Put that in a function and call that on change or just put this code in showCustomer.
Jan 20 '07 #2

100+
P: 157
Hi,
I have two dropdowns. In first dropdown i have two languages say english, persian. When i select english in 2nd dropdown iam able to show list of english movies. Problem is i need first dropdown selected value to use for second dropdown onchange. How can i use first dropdown value for second one?.

this is select box code for second dropdown

<select id="Moviename" name="Moviename" onChange="showCustomer(lan)">

Here lan is language that selected in first dropdown. How can i get that lan value to here???.

Please Help.
Go through this..

http://www.trans4mind.com/personal_d...ripleMenu2.htm
Jan 20 '07 #3

P: 14
If your code for 1st dropdown is
[HTML]<select id="Language" name="Language">[/HTML]
then the following code
Expand|Select|Wrap|Line Numbers
  1. var sel = document.getElementById("Language");
  2. var lan = sel.options[sel.selectedIndex].text;
will give you the value you require. Put that in a function and call that on change or just put this code in showCustomer.

Hi,

<tr>
<td>Moviename</td>
<td><label>
<script>
var sel = document.getElementById("sType");
var lan = sel.options[sel.selectedIndex].text;
</script>
<select id="Moviename" name="Moviename" onChange="showCustomer(this.value, lan)"> </label></td>
</tr>


Using this iam getting only first value of dropdown. Iam not getting selected value. Can you please check.
Jan 20 '07 #4

chunk1978
100+
P: 224
this page was very helpful for me when i was trying to learn how to do the same thing a while back... read the whole page (it's not long) and pay close attention to the "More Options" section where it talks about dropdown menus.

http://www.mediacollege.com/internet.../add-text.html
Jan 20 '07 #5

P: 14
this page was very helpful for me when i was trying to learn how to do the same thing a while back... read the whole page (it's not long) and pay close attention to the "More Options" section where it talks about dropdown menus.

http://www.mediacollege.com/internet.../add-text.html

it doesnt help. thanks for link.
Jan 20 '07 #6

acoder
Expert Mod 15k+
P: 16,027
Hi,

<tr>
<td>Moviename</td>
<td><label>
<script>
var sel = document.getElementById("sType");
var lan = sel.options[sel.selectedIndex].text;
</script>
<select id="Moviename" name="Moviename" onChange="showCustomer(this.value, lan)"> </label></td>
</tr>


Using this iam getting only first value of dropdown. Iam not getting selected value. Can you please check.
You will only get the first value because you are only using the code once on page load. You need to use the code when the second list changes, so put the two lines into your showCustomer function. You can get rid of the second argument, lan, from the function call.
Jan 20 '07 #7

P: 14
Iam not getting it Can you please write a code of it.
Jan 21 '07 #8

Expert 100+
P: 1,892
Iam not getting it Can you please write a code of it.
Bootzwiz,
Why did you report this to me and tell me to write the code? I think you are misunderstanding the purpose of this forum. We are here to help. You need to make a valid effort at producing some code. We are not here to write your functions for you. You need to at least try, post the code you have tried that is not working and state specifically the problem.


Thanks,
Aric
Jan 21 '07 #9

P: 14
sorry....i think i made a mistake instead of click on reply i clicked on report and posted...I made an effort i asked here after i tried everything.

Please ignore it.
Jan 21 '07 #10

acoder
Expert Mod 15k+
P: 16,027
Iam not getting it Can you please write a code of it.
In your showCustomer function include the two lines that you have beginning with
Expand|Select|Wrap|Line Numbers
  1. var sel = ...
Also, get rid of the second argument in showCustomer both when defining the function and calling it:
[HTML]<select id="Moviename" name="Moviename" onChange="showCustomer(this.value)"> [/HTML]
If you still can't figure it out, post your showCustomer code.
Jan 22 '07 #11

Post your reply

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