Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > input name=integer

Reply
Thread Tools

input name=integer

 
 
M
Guest
Posts: n/a
 
      02-07-2007
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
 
Reply With Quote
 
 
 
 
Tim Slattery
Guest
Posts: n/a
 
      02-07-2007
M <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.
>
>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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://members.cox.net/slatteryt
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      02-07-2007
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)
 
Reply With Quote
 
mike_solomon@lineone.net
Guest
Posts: n/a
 
      02-07-2007
On 7 Feb, 17:05, M <M> wrote:
> 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

 
Reply With Quote
 
Matt Kruse
Guest
Posts: n/a
 
      02-07-2007
(E-Mail Removed) 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


 
Reply With Quote
 
mike_solomon@lineone.net
Guest
Posts: n/a
 
      02-07-2007
On 7 Feb, 19:15, "Matt Kruse" <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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

 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      02-07-2007
(E-Mail Removed) said the following on 2/7/2007 2:27 PM:
> On 7 Feb, 19:15, "Matt Kruse" <(E-Mail Removed)> wrote:
>> (E-Mail Removed) 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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Width of text input box vs. password input box cjl HTML 1 10-31-2005 11:46 AM
Which is faster in ASIC: 2-input AND gate or a 2-input multiplexer Weng Tianxiang VHDL 12 08-11-2005 10:50 AM
hide the input box or change the color of input box in html ashutosh Java 3 06-16-2005 02:21 PM
Input Drops With An Empty Input Queue Spiz Cisco 12 05-18-2005 05:28 PM
why does form with only 1 text input and 1 button input submit on enter? Guy HTML 5 12-13-2003 06:44 AM



Advertisments