/    Sign up×
Community /Pin to ProfileBookmark

input box and onchange help needed

OK, can someone tell me what I am doing wrong…

<form name=”form1″ method=”post” action=”<?php echo $PHP_SELF; ?>”>
<input name = “zipcode” size=”10″ value=”<? echo $zipcode; ?>” onchange=”return chk(this)”>

</form>
<script language=”Javascript”>
function chk(frm)
{
frm.form.submit();
}

</script>

All I want to do is when they enter a value it updates the other fields.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliAug 31.2004 — the code you have doesn't update any field.

it just submits the form on click
Copy linkTweet thisAlerts:
@daed17authorAug 31.2004 — ok so how do I do this using javascripts?
Copy linkTweet thisAlerts:
@CharlesAug 31.2004 — What exactly do you mean by "updates the other fields"? What other fields? What do they look like when you've updated them?

It looks like you're just trying to submit the form "onchange". That's easy enough but you'll still need a submit button for we who do not use JavaScript.

[font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<meta name="Content-Style-Type" content="text/css">

<title>Example</title>

<style type="text/css">

<!--

form {width:11em}

label {display:block; margin:1em 0}

input {display:block; margin:auto; width:10em}

button {display:block; margin:auto}

-->

</style>

</head>

<body>

<form method="post" action="<?php echo $PHP_SELF; ?>">

<div>

<label>Zip Code<input type="text" id="zipcode" value="<? echo $zipcode; ?>" onchange="this.form.submit()"></label>

<button type="submit">Submit</button>

</div>

</form>

</body>

</html>[/font]
×

Success!

Help @daed17 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.6,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...