www.webdeveloper.com
Results 1 to 5 of 5

Thread: Using javascript to get form input name and value pairs

  1. #1
    Join Date
    Aug 2007
    Posts
    6

    Using javascript to get form input name and value pairs

    I'm trying to figure out how I can create javascript code in a bookmark that pulls the names and values from the form inputs in a loaded document.

    In addition it would also be nice if the code knew which form has focus and just pulled the input names and values from that form.

    I've been trying to figure it out, but the only portion I could get to work so far is:
    Code:
    javascript:(document.write(document.forms[0].elements[0].name))
    I don't really know where to go from here. Writing javascript in a javascript:() seems to be different and beyond my level.

    Any help would be appreciated. Thanks.

  2. #2
    Join Date
    Aug 2010
    Location
    Baltimore, Maryland, United States
    Posts
    138

  3. #3
    Join Date
    Aug 2007
    Posts
    6
    Sorry. I'll need some more help than that.

  4. #4
    Join Date
    Aug 2007
    Posts
    3,767
    Using JavaScript like that is absolutely identical to writing it any other way, except in one little way. Statements that return a value other than null must be wrapped in void.
    Code:
    javascript:void(mynum = 10);alert(mynum);

  5. #5
    Join Date
    Aug 2007
    Posts
    6
    OK. Thanks.
    Part of my problem was that I was putting parenthesis where they shouldn't go.
    So
    Code:
    javascript:(document.write(document.forms[0].elements[0].name))
    should be
    Code:
    javascript:document.write(document.forms[0].elements[0].name)

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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