1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

JavaScript AHHHH to much for me!

Discussion in 'Web Development' started by onekoolman, Jul 19, 2005.

  1. onekoolman

    onekoolman New Member

    I want this code to work correctly, what I am trying to do is for the billing address if you click the checkbox I want it to un-disable the fields using javascript, and I want it to delete the words if you check the box, if you uncheck I want it to disable them and put the words back, (If thats possible), So far I just cant get it to work right. Here is the code below...
    It is in a php file. Dont go to the homepage I messed it up...
    Here is the code in working action.

    http://www.scrapbooking4ever.com/orderfix.php



     
  2. Mimoun

    Mimoun Administrator Staff Member Director Verified Member

    A late reply but I was just about the help you out.
    I get a 404 error put the script back online and I will try to help you out.
     
  3. onekoolman

    onekoolman New Member

    Well I kinda deleted it, and I dont have the java source, but, I still want to do it on this page

    http://www.scrapbooking4ever.com/order.php

    Yet I dont have any of that javascript source code...
    I want the contact to automatically fill the shipping with the click of a check box, I will work on recreating the code, but if you reply first I will take that.
    Here is the source code of order.php

    http://www.scrapbooking4ever.com/source.php

    I finally put it into the page, after lots of work...

    The code that I was using was from javascript.internet.com it was an auto fill type of script.

    If you can help I would appriciate it.
     
  4. Mimoun

    Mimoun Administrator Staff Member Director Verified Member

    You can do this by using getElementById and giving your input fields an id and giving same value to the 2 ids.

    Here is an online test sample.

    Here is the source code for the script:
    Code:
    <head>
    <title>Script to change input box with javascript</title>
    <script type="text/javascript">
    function changeit()
    {
       document.getElementById('shipfirstname').value=document.getElementById('contactfirstname').value
       document.getElementById('shiplastname').value=document.getElementById('contactfirstlast').value
    }
    </script>
    </head>
    <body>
    <h1>Script to change input box with javascript</h1>
    
    <form action="post.php" method="post" enctype="application/x-www-form-urlencoded">
    Contact info:<br />
    First name: <input id="contactfirstname" name="firstname" type="text" value="" size="12" /><br />
    Last name: <input id="contactfirstlast" name="lastname" type="text" value="" size="12" /><br />
    Shipping info:<br />
    <input name="checkit" type="checkbox" onclick="changeit()" value="" />check to use same as contact info<br />
    First name: <input id="shipfirstname" name="shipfirstname" type="text"  value="" size="12" /><br />
    Last name:<input id="shiplastname" name="shipfirstname" type="text" value="" size="12" /><br />
    </form>
    <br />
    </body>
    </html>