SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting form elements with jQuery

    I am getting form names & values using the following. How can I write the following using jQuery?

    Code:
    var options = '';
    for (i = 0; i < document.formname.elements.length; i++) {
    	var optionName = document.formname.elements[i].name;
    	var optionValue = document.formname.elements[i].value;
    	options += optionName+optionValue;
    }
    There is no practical purpose, just want to know if it is possible to write the following statements in jQuery.

    Code:
    document.formname.elements.length
    document.formname.elements[i].name
    document.formname.elements[i].value
    Thanks for any ideas.

  2. #2
    Barefoot on the Moon! silver trophy
    Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,516
    Mentioned
    51 Post(s)
    Tagged
    1 Thread(s)
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain


Bookmarks

Posting Permissions

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