-
Feb 1st, 2012, 09:49 AM
#1
Thread Starter
Fanatic Member
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?
-
Feb 1st, 2012, 12:27 PM
#2
Re: what is name and value attributes in form
-
Feb 1st, 2012, 11:07 PM
#3
Thread Starter
Fanatic Member
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?
-
Feb 2nd, 2012, 06:02 AM
#4
Re: what is name and value attributes in form
Originally Posted by ADQUSIT
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,...
-
Feb 9th, 2012, 02:03 AM
#5
Thread Starter
Fanatic Member
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?
-
Feb 9th, 2012, 02:56 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|