Welcome to WebmasterWorld Guest from 54.167.22.37

Forum Moderators: open

Message Too Old, No Replies

dynamic dropdown

     

leo gatmaytan

1:46 am on Sep 8, 2010 (gmt 0)



Hi,

I need to know how to create a dynamic dropdown. I already created a simple dynamic dropdown menu but I have a problem.

When the drop down is inside a form, it doesn't work but if it's not, it does work.

here is the code wherein the dropdown and textbox is inside a form:

try to remove the:



<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->


and the


</form>


at the end. It will work once you remove it.










<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script>
function valyusdesc(velvel){
if (velvel == 0)
{return ""}

if (velvel == 1)
{return "1"}
if (velvel == 2)
{return "2"}
if (velvel == 3)
{return "3"}
}

function D1_onchange() {
T1.value = valyusdesc(D1.value)

}
function D2_onchange() {
T2.value = valyusdesc(D2.value)

}
function D3_onchange() {
T3.value = valyusdesc(D3.value)

}

</script>

</head>

<body>

<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p><select
onChange="return D1_onchange()" size="1" name="D1" id="D1" >
<option selected value="0">click here</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select><input type="text" name="T1" id="T1" size="20"><input type="submit" value="Submit" name="B1"></p>
<p><select
onChange="return D2_onchange()" size="1" name="D2" id="D2">
<option value="0" selected>click here</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select><input type="text" name="T2" id="T2" size="20"></p>
<p><select
onChange="return D3_onchange()" size="1" name="D3" id="D3">
<option selected value="0">click here</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select><input type="text" name="T3" id="T3" size="20"></p>
</form>

</body>

</html>

alias

9:54 am on Sep 8, 2010 (gmt 0)

10+ Year Member



Right now the simplest solution in your case is to name your form and use values like FormName.D1.value to get the values.

Fotiman

1:25 pm on Sep 8, 2010 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



In your handlers, you are doing things like this:

T1.value = valyusdesc(D1.value)

But you have not defined what T1 is. You should be doing something like this:

var T1 = document.getElementById('T1');
T1.value = valyusdesc(D1.value);


Then it should work.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month