Results 1 to 5 of 5

Thread: updating textbox in javascript problem - simple question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    updating textbox in javascript problem - simple question

    hi all
    i wrote the folowing javascript code
    <html>
    <head>
    <script language ="javascript">
    function Change()
    {
    document.test1.tbText1.value = 20
    }
    </script>


    <body>
    <form name="test1" method="post" onsubmit ="Change()">
    <input type="text" name="tbText1">
    <br>
    <input type="submit" value="submit">
    </form>

    when i press on the submit button i cant see value 20 in the textbox
    1. why does it happen?
    2. as a result how do i cange in the same way checkbox??
    thanks alot
    Ron

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    continuing

    by the way my aim is to populate form with array (by loop) by clicking submit button

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    continuing

    by the way my aim is to populate form with array (by loop) by clicking submit button

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Code:
    <html>
    <head>
    <script language ="javascript">
    function Change()
    {
    document.test1.tbText1.value = 20
    return false;
    }
    </script>
    <body>
    <form name="test1" method="post" onsubmit ="return Change()">
    <input type="text" name="tbText1">
    <br>
    <input type="submit" value="submit">
    </form>
    The reason why you can't see the value is because the form is submitting (in this case, reloading the page).

    Another method for this would be:

    Code:
    <html>
    <head>
    <script language ="javascript">
    function Change()
    {
    document.test1.tbText1.value = 20
    }
    </script>
    
    
    <body>
    <form name="test1" method="post">
    <input type="text" name="tbText1">
    <br>
    <input type="button" value="submit" onclick="Change()">
    </form>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    thanks alot!!!!!

    thanks alot! for helping

Posting Permissions

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



Click Here to Expand Forum to Full Width