You are trying to change the already existing field correct. I have done it usng 2 field so getting it to work in one field should be simple enough. ok this is a code I used for a pro bono client and I used arrays to fill the fields. I just tested changing a single field and it works well. So here is the code adjust where you like.
Code:
<script language="javascript">
<!--
var arraySelect
var trueDescription
var sel
var len
function Option(desc,value){
//properties of array
this.desc=desc
this.value=value
}
var select1=new Array(6)
select1[0] = new Option("BRAIDED","5");
select1[1] = new Option("CLASSIC","4");
select1[2] = new Option("CLASSIC PQ!","200");
select1[3] = new Option("DRAPED BUST","198");
select1[4] = new Option("NO STEM CR 4","3");
select1[5] = new Option("PL4 STEMLESS","199");
var select2=new Array(18)
select2[0] = new Option("BRAIDED","9");
select2[1] = new Option("BRAIDED GEM!","10");
select2[2] = new Option("BRAIDED N-3","203");
select2[3] = new Option("BRONZE","13");
select2[4] = new Option("CHAIN CENT","201");
select2[5] = new Option("CORONET","7");
select2[6] = new Option("CORONET PQ!","8");
select2[7] = new Option("DOUBLE DIE","15");
select2[8] = new Option("FLOWING HAIR","6");
select2[9] = new Option("FLYING EAGLE","11");
select2[10] = new Option("FUGIO ST UNI","2");
select2[11] = new Option("INDIAN","12");
select2[12] = new Option("INDIAN PQ!","206");
select2[13] = new Option("INDIAN TY 1","205");
select2[14] = new Option("INDIAN CN","204");
select2[15] = new Option("LINCOLN","14");
select2[16] = new Option("POINTED RAYS","1");
select2[17] = new Option("SM DATE N-6","202");
function descriptions(deno) {
sel = document.addWishList.deno
var arraySelect=deno.value
var len=eval(arraySelect+".length")
for (var x=0;x<len;x++){
sel.length=len+2
sel.options[0].text="Any"
sel.options[0].value=0
sel.options[x+1].value=(eval(arraySelect+"["+x+"].value"))
sel.options[x+1].text=(eval(arraySelect+"["+x+"].desc"))
sel.options[len+1].text="None"
sel.options[len+1].value=1
}
}
//-->
</script>
This was obviosly written with a multi dimentional array in mind. I have two fields by default. If you want to use both you will have to change the line
Code:
sel = document.addWishList.deno
to whatever field you wish to change in this case it changes itself. But this is the way it was
Code:
sel = document.addWishList.des
And this is the part the goes in your body
Code:
<form name="addWishList" method="post" action="">
<select name="deno" id="deno" onchange="descriptions(deno)">
<option value="select0">Any</option>
<option value="select1">Large/Small Cent</option>
<option value="select2">Half Cent</option>
</select>
<select name="des" id="des" onchange="alert(this.value)">
<option value="0">Any</option>
<option value="1">None</option>
</select>
</form>
</body>
I am sure you can see where the code names are and stuff so I won't go into a tonne of detail. The field names are des and deno and those names are used above. If you need any help just ask again. If this wasn't what you needed. Well I will try again
Bookmarks