Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 06-13-2007, 10:45 AM loosing li value
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Hi ,

I have the below function that s not exactly running correctly

Code:
function amendHiddenLinks(linkDrag) { 
   document.getElementById('check').innerHTML = document.getElementById('links').value + "<BR>";
   obj =  linkDrag;        // get the parent 
   CN  =  obj.childNodes;  // get nodes
   x   =  0;               // loop variable
   document.getElementById('links').value = "";
   while(x < CN.length){	  
     
	   document.getElementById('links').value +=  CN[x].getAttribute('value') + "||";  	   
       x++;	
	  
   }
    document.getElementById('check').innerHTML = document.getElementById('links').value + "<BR>";
  
}

My problem is that CN[x].getAttribute('value') which is picking up the <li>.value is returning the first numeric only, ...... IF a numeric exists in the string.

IE <li value="link name"> WORKS FINE & returns "link name"
<li value="link 1 name"> FAIL & returns "1"
<li value="link na99me"> FAIL & returns 99
<li value="link 99 past the 10 15, 1"> FAILS & returns 99

Any ideas would be much appreciated. Been buggin me all day lol
__________________

Please login or register to view this content. Registration is FREE

Last edited by numbenator; 06-13-2007 at 10:47 AM..
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 06-16-2007, 05:00 PM Re: loosing li value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It's probably because the value attribute for a li element should be a positive integer only.

And deprecated since HTML4 BTW
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-18-2007, 04:44 AM Re: loosing li value
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Thats understandable although how is ""link 1 name" interpreted as anything other than a string or even a negative number?
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 06-18-2007, 10:25 AM Re: loosing li value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
read your question and your examples the answer should be fairly apparent

it is selecting up to the last numeric if it exists (or the closing quote)

Just put numbers in there (as they should be) and it will probably work as expected.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-18-2007, 10:30 AM Re: loosing li value
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Im sorry i am not with you.

This eg comes from a form where client adds links.

field 1 is link name
field 2 is link url

When the client enters "link 1", link is removed and the number 1 is left iun the string.

Because this is part of a drag and drop, i haev be able to strore this name/value pair in the li

Same with other chr numeric combinations.

You say "read your questions and examples" and things should be apparent, lol. I am sorry but it isn't

also : "Just put numbers in there (as they should be) and it will probably work as expected."
----- i don't want to input just numebrs. I require the client to enter a link url name which may be a combination of numeric and chr.

Any more ideas would be helpful.
__________________

Please login or register to view this content. Registration is FREE

Last edited by numbenator; 06-18-2007 at 10:33 AM..
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 06-18-2007, 12:33 PM Re: loosing li value
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
You say "read your questions and examples" and things should be apparent, lol. I am sorry but it isn't
Quote:
From post#4
it is selecting up to the last numeric if it exists (or the closing quote)
Quote:
----- i don't want to input just numebrs. I require the client to enter a link url name which may be a combination of numeric and chr.
Obviously you can't do this with the value attribute and a <li> element. Unless you ensure the format of the inserted value is always
Code:
value="[name][number]"
with a optional space between name & number.
Even then don't try to validate the page code because it will fail.


2 possible choices that I can see;

1/ add an attribute of your own into the element.

2/ use a different attribute (title would be my choice)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-19-2007, 06:56 AM Re: loosing li value
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Oh Thats Great Input.
Thanks very much. Ill get back to you if works using another attribute
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 06-19-2007, 07:05 AM Re: loosing li value
numbenator's Avatar
Webmaster Talker

Posts: 516
Location: London
Trades: 0
Thats wicked thankyou!
I used a different attricbute ( title ) and everything is working a treat.
Thanks
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Reply     « Reply to loosing li value
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.17559 seconds with 12 queries