/    Sign up×
Community /Pin to ProfileBookmark

Javascript novice onChange select list

Can some expert (or even mildly talented) coder tell me why this code doesn’t work?

[code=html]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<script type=”text/javascript”>
<!–
function VendorSize()
{
if (document.test.blah.value = 1) {mySize = ‘foo’;}
if (document.test.blah.value = 2) {mySize = ‘bar’;}
if (document.test.blah.value = 3) {mySize = ‘zoo’;}

document.test.Populate.value=mySize;
}

//–>
</script>
</head>
<body>

<form name=”test”>
<select name=”blah” onChange=”VendorSize();”>
<option value=”1″ selected>1</option>
<option value=”2″>2</option>
<option value=”3″>3</option>
</select>
<input type=”text” name=”Populate” value=””>
</form>
</body>
</html>
[/code]

I appreciate it!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mochsl99authorApr 20.2007 — I figured it out. I'm such an idiot. The conditional needed to be:

if (document.test.blah.value == 1) {mySize = 'foo';}

NOT

if (document.test.blah.value = 1) {mySize = 'foo';}
×

Success!

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