/    Sign up×
Community /Pin to ProfileBookmark

Javascript Array

Hi Everyone,

I have a problem regarding inserting a value that is to be passed inside my javascript select drop down. This was my initial code:

catopt = new Array;
catopt[0] = “Select”, “00”;
catopt[1] = “Pieces”, “0”;
catopt[2] = “Release Notes”, “2”;
catopt[3] = “White Paper”, “1”;
catopt[4] = “Other”, “9”;

But when I pass the above form values, only the text gets passed and not the
value, like 00, 2, 0 ect…
So I changed my code to the below, so that those codes can be passed, new
code is:

catopt = new Array;
catopt[0] = new Option(“Select”, “00”);
catopt[1] = new Option(“Pieces”, “0”);
catopt[2] = new Option(“Release Notes”, “2”);
catopt[3] = new Option(“White Paper”, “1”);
catopt[4] = new Option(“Other”, “9”);

writeln(‘<SELECT NAME=”SelectPrimary” onChange=”changeMenu(this.form)”>’);
tot = catopt.length;
for (i = 0; i < tot; i++)
writeln(“<OPTION>” +catopt[i]);
writeln(“</SELECT>”);

But when I open the page in IE, the only text I see in my drop down is:
object, object, object, and in Netscape: [objectHTMLOptionElement], as if I
had inputed nothing.

I would greatly appreciate any help on this matter.

Thanks in advance!
Much Appreciated!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryDec 02.2003 — Use the second version of your code, and try this:

writeln('<OPTION value="' + catopt[i].value + '">' +catopt[i].text + '</OPTION>');



Adam
Copy linkTweet thisAlerts:
@Venom77authorDec 02.2003 — Wow that was a fast reply.

Thanks for the help Adam, that worked perfectly.
×

Success!

Help @Venom77 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.15,
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,
)...