automatic form fillup

Discussion in 'JavaScript' started by PinoyIto, Oct 9, 2008.

  1. #1
    Is there a way that using javascript I can automatically fillup a form...

    thanks in advance
     
    PinoyIto, Oct 9, 2008 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    yes, there is.
     
    dimitar christoff, Oct 9, 2008 IP
  3. PinoyIto

    PinoyIto Notable Member

    Messages:
    5,863
    Likes Received:
    170
    Best Answers:
    0
    Trophy Points:
    260
    #3
    can you please show sample code please
     
    PinoyIto, Oct 9, 2008 IP
  4. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #4
    this is a very broad subject / specification.

    but... to put things in perspective, something along the lines of:
    
    Name: <input type="text" id="name" name="name" /> <button id="me" data-name="dimitar"><< use your name</button>
    ...
    
    <script>
    document.getElementById("me").onclick = function() {
       document.getElementById("name").setAttribute("value", this.getAttribute("data-name"));
    }
    </script>
    
    PHP:
    clicking the button will insert the value of data-name property into the input form field.

    p.s. i've not really run this to test it - it ought to work. you can apply a similar principle that references your form input fields and puts data into them...
     
    dimitar christoff, Oct 9, 2008 IP