RE: help with drop-downs and onChange
you can pass a reference the current object in the onChange event, as this. select... > function setDept1(selectbox) { alert selectbox.selectedIndex; } Untested code, a shot from the hip -- but you get the concept.. ? :) /Hugo - Hugo AhleniusE-Mail: [EMAIL PROTECTED] Project Officer Phone:+46 8 230460 UNEP GRID-ArendalFax:+46 8 230441 Stockholm OfficeMobile:+46 733 467111 WWW: http://www.grida.no - | -Original Message- | From: cf coder [mailto:[EMAIL PROTECTED] | Sent: Thursday, March 25, 2004 11:36 | To: CF-Talk | Subject: help with drop-downs and onChange | | I have two select boxes (drop-down boxes) in my form, they | both have a different onChange function. I want both the drop | downs to call the same function. | | select name=select1 id=select1 | > |blah blah | /select | | select name=select2 id=select2 | > |blah blah | /select | | Hope I am making sense. | | Here is my code. | function setDept1() | { |if (document.frm.select1.selectedIndex != 0) { |myindex=document.frm.select1.selectedIndex; |var document.frm.hidselect.value = | document.frm.select1.options[myindex].value; |return true; |} | } | | How do I pass the name of the drop-down box to the function | and then assign the selected option value to a hidden | variable. Can anybody please help me get round this problem. | Best regards, | cfcoder | | | | __ | Do you Yahoo!? | Yahoo! Finance Tax Center - File online. File on time. | http://taxes.yahoo.com/filing.html | | [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with drop-downs and onChange
select name=select1 id=select1 > blah blah /select select name=select2 id=select2 > blah blah /select Hope I am making sense. Here is my code. function setDept1() { if (document.frm.select1.selectedIndex != 0) { myindex=document.frm.select1.selectedIndex; var document.frm.hidselect.value = document.frm.select1.options[myindex].value; return true; } } How do I pass the name of the drop-down box to the function and then assign the selected option value to a hidden variable. Can anybody please help me get round this problem. Best regards, cfcoder > Or you can pass the name explicitly. > Then in your function use this as the reference. Mike [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: help with drop-downs and onChange
I use one of two ways, but i prefer it to use the event object. ex. select name=select1 id=select1 > blah blah /select select name=select2 id=select2 > blah blah /select function setDept() { mySelect = event.srcElement; if(mySelect.selectedIndex != 0) { myindex=mySelect.selectedIndex; var document.frm.hidselect.value = mySelect.options[myindex].value; } return true; } Tyler Clendenin GSL Solutions _ From: cf coder [mailto:[EMAIL PROTECTED] Sent: Thursday, March 25, 2004 5:36 AM To: CF-Talk Subject: help with drop-downs and onChange I have two select boxes (drop-down boxes) in my form, they both have a different onChange function. I want both the drop downs to call the same function. select name=select1 id=select1 > blah blah /select select name=select2 id=select2 > blah blah /select Hope I am making sense. Here is my code. function setDept1() { if (document.frm.select1.selectedIndex != 0) { myindex=document.frm.select1.selectedIndex; var document.frm.hidselect.value = document.frm.select1.options[myindex].value; return true; } } How do I pass the name of the drop-down box to the function and then assign the selected option value to a hidden variable. Can anybody please help me get round this problem. Best regards, cfcoder __ Do you Yahoo!? Yahoo! Finance Tax Center - File online. File on time. http://taxes.yahoo.com/filing.html _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]