473,387 Members | 1,520 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,387 software developers and data experts.

input name=integer

M
Hello,

Here is my input field :

<input name='5' type='text'/>

I can't change it. I must use an integer for the name.

I need javascript code to get its value.

But document.getElementById("myform").elements["5"].value
does not give the right result, it gives the value from another field
(the 5th of the list, not the one whose name is 5).

Please help.

Thanx !
M
Feb 7 '07 #1
8 4029
M wrote on 07 feb 2007 in comp.lang.javascript:
Here is my input field :

<input name='5' type='text'/>

I can't change it. I must use an integer for the name.

I need javascript code to get its value.
'need' and 'must', who is the boss overthere?
But document.getElementById("myform").elements["5"].value
does not give the right result, it gives the value from anot
var myF = document.getElementById('myform');
var myT = myF.getElementsByTagName('input');

for (var r=0;r<myT.length;r++)
if (myT[r].name == '5')
var result = myF[r].value;
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 7 '07 #2
On 7 Feb, 17:05, M <Mwrote:
Hello,

Here ismyinput field :

<input name='5' type='text'/>

I can't change it. I must use an integer for the name.

I needjavascriptcode to get its value.

But document.getElementById("myform").elements["5"].value
does not give the right result, it gives the value from another field
(the 5th of the list, not the one whose name is 5).

Please help.

Thanx !
M
Use

<input type="text" name="5" value="test" id="5">

document.getElementById("5").value

to use document.getElementById you must set an id

Feb 7 '07 #3
M wrote:
<input name='5' type='text'/>
But document.getElementById("myform").elements["5"].value
does not give the right result,
document.getElementById("myform").elements.namedIt em("5").value
--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 7 '07 #4
M wrote:
Hello,

Here is my input field :

<input name='5' type='text'/>

I can't change it. I must use an integer for the name.
Yes you can
>
I need javascript code to get its value.

But document.getElementById("myform").elements["5"].value
does not give the right result, it gives the value from another field
(the 5th of the list, not the one whose name is 5).
function getValueOfNamedInput(V,form){
f=form.length
while(f--){if(form[f].name==V)return form[f].value;}
}

Mick
Feb 7 '07 #5
mi**********@lineone.net wrote:
<input type="text" name="5" value="test" id="5">
Not valid, since id's may not begin with a number.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Feb 7 '07 #6
On 7 Feb, 19:15, "Matt Kruse" <newsgro...@mattkruse.comwrote:
mike_solo...@lineone.net wrote:
<input type="text" name="5" value="test" id="5">

Not valid, since id's may not begin with a number.

--
Matt Krusehttp://www.JavascriptToolbox.comhttp://www.AjaxToolbox.com
Well I tested it before I posted and it worked under IE :)

Feb 7 '07 #7
M <Mwrote:
>Hello,

Here is my input field :

<input name='5' type='text'/>

I can't change it. I must use an integer for the name.

I need javascript code to get its value.

But document.getElementById("myform").elements["5"].value
does not give the right result, it gives the value from another field
(the 5th of the list, not the one whose name is 5).
How about

document.getElementsBy Name("5")[0]

Assuming there's only one item with name="5" in your page.

--
Tim Slattery
Sl********@bls.gov
http://members.cox.net/slatteryt
Feb 7 '07 #8
mi**********@lineone.net said the following on 2/7/2007 2:27 PM:
On 7 Feb, 19:15, "Matt Kruse" <newsgro...@mattkruse.comwrote:
>mike_solo...@lineone.net wrote:
>><input type="text" name="5" value="test" id="5">
Not valid, since id's may not begin with a number.

Well I tested it before I posted and it worked under IE :)
Being able to say "it worked under IE" doesn't mean a whole lot though.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 8 '07 #9

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

Similar topics

38
by: Keith | last post by:
I've been reading and looking on the internet - but I just can't fin this. Perhaps I'm approaching this the wrong way - code-wise I'm attempting to learn how "things" work in VBNET by creating...
3
by: mike | last post by:
I have the following view definition Column | Type | Modifiers ----------------+-----------------------+----------- bcode | character varying(15) | subhead ...
27
by: code_wrong | last post by:
Visual Basic (not dot net) what is the best way to check the User has entered an integer into an InputBox? isNumeric() checks for a numeric value .. but does not notify of numbers with decimal...
11
by: sang | last post by:
Hi I am writing a application program that checks if the input is integer, if it is integer print the integer value only. i have no idea about that please any one help me. Thanks Sang
4
saza
by: saza | last post by:
heyya! again i have a problem, im trying to compare if either the int input "choice" is really an integer or not. enter an integer input (int choice) if input is an integer do this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.