uffe34Medlem sedan aug. 200214 inlägg Hej, har tre dynamiska dropdownboxar som skiftar med valen i den första osv... Jag får bara ut värdet eller datat i den första, med det första valet man gör, men inte i den andra, resp den tredje.
kod för att få ut värdet från den första:
document.myChoices.firstChoice[document.myChoices.firstChoice.selectedIndex].text
behöver hjälp!! :l
mikkeXMedlem sedan aug. 2002477 inlägg Posta din kod så blir det enklare.
uffe34Medlem sedan aug. 200214 inlägg function set2(form)
{
var tmp = getCookie("KAKA");
if(tmp != null)
setCookie("KAKA" ,tmp + " " + arrCat_id[document.myChoices.firstChoice.value] + " " + document.myChoices.firstChoice[document.myChoices.firstChoice.selectedIndex].text + " " + form.date.value + " " + form.time.value ,expdate);
else
setCookie("KAKA" ,arrCat_id[document.myChoices.firstChoice.value] + " " + document.myChoices.firstChoice[document.myChoices.firstChoice.selectedIndex].text + " " + form.date.value + " " + form.time.value ,expdate);
}
//***************************************************
function selectChange(control, controlToPopulate, ItemArray, GroupArray, ValueArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {
// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null;
}
// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "[Valj]" ;
controlToPopulate.add(myEle) ;
// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// och här för att lägga in i selectboxarna! som du ser måste jag ha värderna för att sätta de till cookies!! Vi behöver inte gå inpå varför! Men det behövs..iaf..
<form name=myChoices action ="path/" method = "post">
<tr bgcolor="lightblue">
<td width=120>
<SELECT id=firstChoice name=firstChoice onchange="selectChange(this, myChoices.secondChoice, arrItems1, arrItemsGrp1, arrItemsValue1);">
<option value = 0 selected> [Välj] </option>
<script>for(var i in arrCat_name)
{
document.write('<option value="'+i+'"> ' +arrCat_name*+'</option>')
}
</script>
</SELECT></td>
<td width=120><SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thi\
rdChoice, arrItems2, arrItemsGrp2, arrItemsValue2);">
</SELECT></td>
<td width=120><SELECT id=thirdChoice name=thirdChoice>
</SELECT></td></tr>
<table>
<tr><td width=120><b>Datum</b></td><td><b>Tid </b></a></td>
</tr>
<table>
<tr bgcolor="lightblue"><td width=120><b><INPUT TYPE=text size="11"name= "date" VALUE = "yyyy-mm-dd"></b></td>
<td><b><INPUT TYPE=text size="4" name= "time" VALUE = "hh:mm"></b></td>
</tr>
<table>
<tr><td width=120><INPUT TYPE=button value= "Rapportera" onClick = "return verify()"></td>
<td><INPUT TYPE=submit value = "Visa Rapport" onClick="parent.location.reload()">
</td></tr>
</FORM>
<SCRIPT>*