LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-27-2008, 10:47 PM   #1
UMG:Chicken_Sop
Member
 
Registered: Nov 2007
Location: Neptune, NJ (exit 100)
Distribution: Slack, Solaris, whatever I have space for
Posts: 32

Rep: Reputation: 16
!? element names beginning with number break javascript???


Just something weird that I ran into and thought I'd mention it...

I've set up an ordering page where a customer selects the quantity of coffee bags that they want from a dropdown, the quantity is multiplied times the price, and the subtotal is displayed in a text field to the right. Pseudoexplained, a dropdown onchange calls a javascript function to multiply this.value of the dropdown times the price and update the value of a readonly text input.

Here's the weird part: if the name of the text input starts with a number, it doesn't work, but, if the input text name starts with a letter, it works fine!!!!!

For example, if I name the text input "sub_10001000" it works fine, but if I name it "1sub_10001000" it doesn't work! What a pain to figure this out when I wanted to use numeric product ID's for names!

Wanna see it in action check the page below. Validated! In the first line the name starts with a letter; in the second, I just copied and pasted the row and added "1" in front of the input-text name:

http://www.miklas.org/test/club2

\|/7PH?! If I didn't know better I'd say that I found a bug in Javascript. Unless there's some restrictions on input value names that I don't know about.

Tested in FireFox 2.0.0.3 and Konqueror 3.5.7: Exact same behavior.

Last edited by UMG:Chicken_Sop; 01-28-2008 at 02:43 AM.
 
Old 01-27-2008, 11:12 PM   #2
lakris
Member
 
Registered: Sep 2004
Location: Stockholm, Sweden
Distribution: Ubuntu, RedHat, SuSe, Debian, Slax
Posts: 102

Rep: Reputation: 15
Quote:
Originally Posted by UMG:Chicken_Sop View Post
If I didn't know better I'd say that I found a bug in Javascript. Unless there's some restrictions on input value names that I don't know about.
Not sure, but in some languages You must not name variables or functions etc, with a leading number, check the syntax rules for Javascript. I guess it will tell You.

/Lakris
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Review: Beginning JavaScript 3rd Edition LXer Syndicated Linux News 0 05-25-2007 11:16 AM
Shell Script that sorts data with number beginning on each line. sunksullen Programming 12 05-09-2007 03:35 PM
JavaScript: Want to get the amount of html 'names'. RHLinuxGUY Programming 1 12-06-2006 01:52 PM
Discovering position of an element in JavaScript Napalm Llama Programming 4 09-07-2005 03:59 PM
number of element in a array of pointer? os2 Programming 7 03-09-2005 11:50 AM


All times are GMT -5. The time now is 09:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration