---
title: "Dropdownbox?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/javascript/56369-dropdownbox"
topic: "JavaScript"
topic_url: "https://www.webforum.nu/amne/javascript"
author: "uffe34"
published: "2002-10-18T06:50:54.000Z"
updated: "2002-10-18T18:38:53.000Z"
replies: 2
views: 192
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/javascript/56369-dropdownbox"
---

# Dropdownbox?

## #1 — uffe34, 2002-10-18T06:50Z

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

Permalänk: https://www.webforum.nu/p/56369

## #2 — mikkeX, 2002-10-18T08:10Z

Posta din kod så blir det enklare.

Permalänk: https://www.webforum.nu/p/826681

## #3 — uffe34, 2002-10-18T18:38Z

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&auml;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\>*

Permalänk: https://www.webforum.nu/p/827253

---

Tråden på webben: https://www.webforum.nu/amne/javascript/56369-dropdownbox
