/    Sign up×
Community /Pin to ProfileBookmark

Sending string value in a multiple drop down

I’ve been working with this code for a few days now, and I cant figure out how to send a value. I want to send the first quotes as “value”,”text” and the next as text.

[code]<html>
<head>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();

arrItems1[0] = “1026.4”,”PC 1026.4 – Mentally ill Escape”;
arrItemsGrp1[0] = 1;
arrItems1[1] = “118”,”PC 118 – Perjury”;
arrItemsGrp1[1] = 1;
arrItems1[2] = “12020”,”PC 12020 – Weapon Laws,Felony”;
arrItemsGrp1[2] = 1;
arrItems1[3] = “12025”,”PC 12025 – Carrying Concealed Firearm”;
arrItemsGrp1[3] = 1;
arrItems1[4] = “1203.2”,”PC 1203.2 – Misdemeanor Probation Violation”;
arrItemsGrp1[4] = 1;
arrItems1[5] = “12031”,”PC 12031 – Weapon Laws, Misdemeanor”;
arrItemsGrp1[5] = 1;
arrItems1[6] = “12280”,”PC 12280 – Assault Weapons, Manufacture, Distribution, Possession”;
arrItemsGrp1[6] = 1;

var arrItems2 = new Array();
var arrItemsGrp2 = new Array();

arrItems2[323] = “1026.4 – Mentally ill Escape,1026.40462”;
arrItemsGrp2[323] = 1
arrItems2[324] = “118 – Perjury,1180325”;
arrItemsGrp2[324] = 2
arrItems2[325] = “12020 – Weapon Laws, Felony,120200151”;
arrItemsGrp2[325] = 3
arrItems2[326] = “12025 – Carrying Concealed Firearm,120250150”;
arrItemsGrp2[326] = 4
arrItems2[327] = “1203.2 – Misdemeanor Probation Violation,1203.20399”;
arrItemsGrp2[327] = 5

function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myElement ;
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=fCASE.CAS.options.length;q>=0;q–) fCASE.CAS.options[q] = null;
}
// ADD Default Choice – in case there are no values
myElement = document.createElement(“option”) ;
myElement.value = 0 ;
myElement.text = “[SELECT]” ;
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 )
{
myElement = document.createElement(“option”) ;
myElement.value = x;
myElement.text = ItemArray[x] ;
controlToPopulate.add(myElement) ;
}
}
}

function setUpperCase(obj) {
obj.value = obj.value.toUpperCase();}
function setUpperAll() {
for(i=0; i < document.fCASE.elements.length; i++){
if (document.fCASE.elements[i].type == “text” && document.fCASE.elements[i].value != “”) {
setUpperCase(document.fCASE.elements[i]);
}0
}
}
// End –>
</script>
</head>
<body>

<form name=fCASE method=get action=”http:HammerHead/CASEQ” onSubmit=setUpperAll()>
<table>
<TR><TD>CASE</TD><TD><INPUT TYPE=SUBMIT VALUE=”Send”> <INPUT TYPE=RESET VALUE=”Clear”></TD></TR>
<TR><TD>Text:</TD><TD><INPUT NAME=Text TYPE=TEXT onBlur=setUpperCase(this)> (Optional)</TR>
<TR><TD>Time:</TD><TD><INPUT NAME=Time TYPE=TEXT onBlur=setUpperCase(this)> (Optional)</TD></TR>
<tr><td>Code:</td><td><SELECT id=firstChoice name=firstChoice onchange=”selectChange(this, fCASE.TYPE, arrItems1, arrItemsGrp1);”>
<option value=0 SELECTED>[SELECT]</option>
<option value=1>PC</option>
<option value=2>VC</option>
<option value=3>Other</option>
</SELECT>
</td>
<tr><td>Type:</td><td><SELECT id=TYPE name=TYPE onchange=”selectChange(this, fCASE.CAS, arrItems2, arrItemsGrp2);”>
</SELECT>
</td>
</tr>
<tr><td>CAS:</td><td><SELECT id=CAS name=CAS>
</SELECT>
</td>
</table>
</form>
</body>
</html>[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@furiousferretauthorApr 20.2004 — I've got the values to work, but I dont know how to pass the text now, I have it broken down into a small area:

}
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "[SELECT]" ;
controlToPopulate.add(myEle) ;

for ( x = 0 ; x &lt; ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option");
myEle.value = ItemArray[x] ;
myEle.text =
controlToPopulate.add(myEle) ;
}
}
}


myEle.text is where I'm having a problem, in the array I have "value","text" and I'm not sure how to pass the text over.

Any help is appreciated....
×

Success!

Help @furiousferret spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...