Use Of Id attribute in Html

Use Of Id attribute in Html

View Answers

May 26, 2009 at 12:22 PM

Hi Friend,

The id attribute specifies a unique id for an HTML element that assigns a identifier value to a tag. Each element can only have one id.

It can be used by a JavaScript or by CSS to make changes or style the element with the specified id.

Now we are providing you the code that will display textbox value and selected combobox value using id attribute:

1) TextBox

<html>
<head>
<script type="text/javascript">
function hello(){
var message=document.getElementById("tex");
alert("You have entered the message "+message.value);
}
</script>
</head>
<body>
<input id="tex" type="text">
<input type="button" onclick="hello();" value="Click">
</body>
</html>

2)ComboBox

<html>
<head>
<script type="text/javascript">
function hello(){
var combo = document.getElementById("com");
var comboValue = combo.options[combo.selectedIndex].text
alert("You have selected: "+comboValue);
}
</script>
</head>
<body>
<select id="com" name="combo">
<option value="0">-Select-</option>
<option value="1">India</option>
<option value="2">USA</option>
</select>
<input type="button" onclick="hello();" value="Click">
</body>
</html>

Thanks









Related Tutorials/Questions & Answers:
Use Of Id attribute in Html - Development process
Use Of Id attribute in Html    Hi, I am new to web page development.Could u plz explain what is use of id attribute in html. For example..., The id attribute specifies a unique id for an HTML element that assigns
HTML Action attribute - Java Beginners
HTML Action attribute  I have folder structure like this WebApplication1 -web -emp_event.jsp -src -java... In action Attribute I want to give emp_event.java class. But When I run I am
Advertisements
<html:option > with "selected" attribute - Struts
with "selected" attribute  how to display formbean object with "selected" attribute in . please help me
Horizontal Rule Attribute in HTML
Horizontal Rule Attribute in HTML   ... an example from Horizontal Rule Attribute in HTML. In this Tutorial, the code apply... paragraphs of size 6  in html page.  The common attribute used
Use of immediate attribute
Use of immediate attribute  What is the use of immediate attribute
Use of jQuery attribute filters
Use of jQuery attribute filters       Use of jQuery attribute filters In this section you will learn how to use attribute filters of jQuery.ADS_TO_REPLACE_1 Using jQuery
HTML Button onclick get ID of Button
HTML Button onclick get ID of Button  How i can get the ID of HTML Button on click?? I wanted to do it using JavaScript function. Thanks
How to use contentType Attribute in JSP?
How to use contentType Attribute in JSP?  Hi, I am learning JSP and now trying to use the contentType Attribute in JSP. tell me how to use the contentType Attribute in JSP? Thanks
HTML5 target attribute, Definition and use of target attribute.
HTML5 target attribute, Definition and use of target attribute. In this tutorial we will inform about the target attribute of <area> tag in html5. This attribute is used for specifying the name of  the window or frame where
PHP HTML Form Method Attribute
Topic : PHP HTML Form Method Attribute Part - 3 The second attribute in the form tag is Method. With the help of Method attribute, we can tell the browser... information in the URL sent by the user. You can use get method when the information
HTML5 audio loop, Use of loop attribute of audio tag in  HTML5.
HTML5 audio loop, Use of loop attribute of audio tag in  HTML5. Introduction:Loop attribute is used for reputation of audio or music. It repeats... will be repeated automatically. loop attribute: Attribute Value
HTML5 audio autoplay, Use of autoplay attribute in audio tag.
HTML5 audio autoplay, Use of autoplay attribute in audio tag. Introduction:The autoplay is an audio tag attribute. It is only supported by HTML5. When... web page, music will start automatically . autoplay attribute: Attribute
HTML5 audio autobuffer, Use of autobuffer attribute in audio tag.
HTML5 audio autobuffer, Use of autobuffer attribute in audio tag. Introduction:The autobuffer attribute has Boolean value. It is available in audio tag. Autobuffer attribute is used for buffering a file in advance. It continues
Rel attribute in area tag, Use of rel attribute in area tag.
Rel attribute in area tag, Use of rel attribute in area tag. In this tutorial, you will see the use of rel attribute of area tag and how to implement. The rel (relationship) attribute defines the relationship between current page
MySQL Attribute
MySQL Attribute This example illustrates how to use the COLLATE attribute in MySQL. In this example we use the COLLATE attribute to define the attribute... and collation for the column. Query CREATE TABLE atttribute (attribute_name CHAR
Hreflang Attribute, Use of hreflang attribute of anchor tag in HTML5.
Hreflang Attribute, Use of hreflang attribute of anchor tag in HTML5. In this tutorial, we will see the use of hreflang attribute and how to implement. Hreflang gives the language of linked document. This attribute can be used when
Target attribute in anchor tag, Use of target attribute of anchor tag in HTML5.
Target attribute in anchor tag, Use of target attribute of anchor tag in HTML5. In this tutorial, we will see the use of target attribute of anchor tag in HTML5. Target attribute tells the browser where to display linked document
Rel attribute in anchor tag, Use of rel attribute in anchor tag.
Rel attribute in anchor tag, Use of rel attribute in anchor tag. Description:You will see the use of rel attribute of anchor tag and how to implement. The rel (relationship) attribute defines the relationship between current page
id
id  how to find date of birth and gender in id in html with the help of javascript
contentType attribute in the page directive
contentType attribute in the page directive  How use contentType attribute in the page directive ?   contentType attribute is used to set the mime type and character set of the JSP. The user can make use of any MIME
HTML
HTML  What is a tag? How can we use MARQUEE in HTML
Maven Repository/Dependency: nanning | nanning-attribute
Maven Repository/Dependency of Group ID nanning and Artifact ID nanning-attribute. Latest version of nanning:nanning-attribute dependencies. # Version Release Date You can read more
HTML
. If you have to create a website you have to use the HTML for creating pages...;  Use of Text Field By using form in HTML... attribute bgcolor and putting any color value into it in HTML Page.  
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
HTML
HTML  What is Semantic HTML? What are the reasons for validating a HTML
HTML
HTML  What is SPAN in HTML
JDOM Attribute Example, Different method of Attribute class.
/>]  Name of attribute : id Download this code... JDOM Attribute Example, Different method of Attribute class. This tutorial explains the use of the  getParent() and getQualifiedName
Set Background Colors and Images in HTML
also be set to a background image. For this we use the body attribute...;Example on the use of Background image in HTML </title></head> <... Set Background Colors and Images in HTML
html
html  diffrence between html and xml
html
html  How to add the calendar in html code
HTML
HTML  What is HTML? What is a Hypertext link
HTML
HTML  What is HTML? What is a Hypertext link
Html
Html  What is HTML? What is a Hypertext link
HTML
HTML  What is BODY in HTML document
html
add a header in the html page  what we can do to add a header in the html page
HTML Button Size
HTML Button Size       Button in HTML is used to submit HTML page. Understand with Example ADS_TO_REPLACE_1 The Tutorial illustrate an example from HTML Button size. In this Tutorial
HTML
HTML  How do we specify page breaks in HTML
html
html  how to convert html page into jsp page
html
html  i want a registration page in html with good background
HTML
HTML  how can we give the unlimited size in the html
html
html  what we can do to add a header in the html page
html
html  what we can do to add a header in the html page
Anchor tag attributes in HTML5, Define the type attribute of anchor tag.
  In this tutorial, we will see the use of type attribute of anchor tag . The type attribute of anchor tag specifies the MIME (multipurpose internet... mail.Example text/plain, text/html, text/xml etc. Declaration Syntax : Declaration
HTML
HTML  Hi, What is the full form of HTML? Thanks (adsbygoogle = window.adsbygoogle || []).push({});   Hi, The HTML stands for HyperText Markup Language. HTML is used to create webpage for world wide web
html
html  sir i am new to eclipse and i am created a html program and also tomcat is running successfully in side the eclipse.but now how i deploy that html program in the eclipse
Button disabled in HTML5, Example of autofoucs and disabled attribute.
the use of disabled and autofocus attribute of button tag. If disabled attribute... attribute is available in button tag. It specifies that controls will be focus automatically, when page load. Attributes of type tag: Attribute
html
html  Can we Access database through html page and how,if not then why
HTML
HTML  How do we create a link? What are the three types of form tags in HTML
html
html  how we can give the form actions in html after register button in the login page
html
Adding Header in HTML  what we can do to add a header in the html page

Ads