dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: input box and onchange help needed

  1. #1
    Join Date
    Jun 2003
    Location
    Memphis, TN
    Posts
    160

    Exclamation 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.

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,136
    the code you have doesn't update any field.
    it just submits the form on click
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Jun 2003
    Location
    Memphis, TN
    Posts
    160
    ok so how do I do this using javascripts?

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    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.

    <!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>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles