473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How I can use the id in javascript

hak
Hi
How I can use the id in javascript to get an information or to populate the
text control
exemple <input type="text" id=1 name="name" value=""/>

I need help please.

Jul 20 '05 #1
3 6960
hak wrote:
How I can use the id in javascript to get an information or to populate
the text control
exemple <input type="text" id=1 name="name" value=""/>


First you use valid (X)HTML.

If you are using HTML, you shouldn't have that "/" in there.
In you are using XHTML then you must quote all your attribute values.
Either way, id="1" isn't valid, because ids must begin with a letter.

Then you use DOM.

document.getElementById('value-of-id-attribute')

will return a reference to the element. Then you can access whatever
properties of it you like, such as the value.

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #2
On Wed, 3 Mar 2004 16:04:28 -0500, in comp.lang.javascript "hak"
<s_**********@hotmail.com> wrote:
| Hi
| How I can use the id in javascript to get an information or to populate the
| text control
| exemple <input type="text" id=1 name="name" value=""/>
|
| I need help please.


<input type="text" id="name1" name="name" value="" />

//--- get value
var id = getElementById("name1").value;

//--- set value
getElementById("name1").value = "1234";
---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 20 '05 #3
Fixed missing document. instruction.

On Thu, 04 Mar 2004 04:42:01 GMT, in comp.lang.javascript Jeff North
<jn****@yourpantsbigpond.net.au> wrote:
| On Wed, 3 Mar 2004 16:04:28 -0500, in comp.lang.javascript "hak"
| <s_**********@hotmail.com> wrote:
|
| >| Hi
| >| How I can use the id in javascript to get an information or to populate the
| >| text control
| >| exemple <input type="text" id=1 name="name" value=""/>
| >|
| >| I need help please.
|
| <input type="text" id="name1" name="name" value="" />
|
| //--- get value var id = document.getElementById("name1").value;|
| //--- set value document.getElementById("name1").value = "1234";| ---------------------------------------------------------------
| jn****@yourpantsbigpond.net.au : Remove your pants to reply
| ---------------------------------------------------------------


---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.