Results 1 to 6 of 6

Thread: what is name and value attributes in form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    what is name and value attributes in form

    Hi, when we write the code in html that

    Username: <input type = "text" name = "Username" value = "VBFORUMS">

    Please assist me that what is name attribute and what is value attribute and what is purpose to write and what happens if we don't write it?

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: what is name and value attributes in form

    Well Samba, I studied these links but its still not completely clear to me that what is name and value attribute?

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: what is name and value attributes in form

    Quote Originally Posted by ADQUSIT View Post
    Well Samba, I studied these links but its still not completely clear to me that what is name and value attribute?
    Read about the "definition" in those links, which Samba had given you. If you still have trouble, there is a "Try it yourself" button, which can be used to test it. Play with it by changing the name and value.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2010
    Posts
    965

    Re: what is name and value attributes in form

    I tried akhileshbc, but still not clear to me, that where exactly we need to use?

  6. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: what is name and value attributes in form

    Name is the attribute to identify that particular element.
    And value is the attribute to display a value inside it.

    In your example,
    Code:
    <input type = "text" name = "Username" value = "VBFORUMS">
    the above code will display a text box and it's name is "Username" and inside it, it will display "VBFORUMS".

    When you submit a form to a serverside page(eg: PHP, JSP, ASP, etc..), the submitted data would contain the "name" and "value". So, if you want to access the value entered by user in the textbox for "Username", you can use the name attribute to access it.

    In PHP, an example would look like this:
    PHP Code:
    $username $_POST['Username'];

    // Above code is for forms submitted via POST method and below is for GET method

    $username $_GET['Username']; 
    So, when you use it like above, the variable "$username" will hold the value entered by the user(eg: "VBFORUMS")

    That is the case of server side!
    In client side also, this is useful. Say, if you want to validate the username entered by an user. So, via JavaScript, you could access the textbox named "Username" and get its value and check it.

    Consider this simple example: in a class there are several students. If those students don't have a name, teacher can't call them and ask them questions(this is an example, so don't ask me whether the teacher could point out some one and ask questions )
    So, if teacher knows his students names, he could easily call them and ask questions.

    So, consider the name of the student as the "Name" attribute and the answer from the student as the "Value" attribute.

    I hope you understand the idea.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

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