• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Geting the value of checkbox when the value containes more than one word

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am building my page with javascript which contains check boxes
for(i=0;i<pair.length(); i++){
t+="<INPUT type='checkbox' name='chkCookieBox' value=";
t+= Id ;
t+= ":" ;
+=Name ;
}
document.getElementById.('bookmark')innerHTML=t;
}

id and name = 100:went to school, 104:came from school etc But when i get a value of the same checkboxes in different function
oName = document.getElementsByName("chkCookieBox");
if(oFavs)
{
for(var i=0;i<oName.length;i++) {
if(oName[i].checked == false) {
alert("oName[ii]"+ oName[i].value);
}}}

the alert msg shows me only 100:went ie only the first word of the name. Could anyone please let why its truncating the Name if it has more then one word.
[ December 02, 2007: Message edited by: Anju Rao ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please edit your post and show the code separately inside UBB code tags. Please read this for more information. Trying to read unformatted code inside a paragraph is just too dang hard.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you do not have quotes around the value's string.

You really should look into using createElement to build elements instead of using innerHTML

Example code here: http://www.pascarello.com/examples/createElement.html

view the source to see how to use it.

Eric
 
Anant Rao
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you do not have quotes around the value's string....

Could you please let me know where you were mentioning about the quotes
if I place the quots around the alert statement it prints as it is
alert("oName[ii]"+ 'oName[i].value');

thanks
Anju
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anju Rao:
Could you please let me know where you were mentioning about the quotes


He means where you write out the <input tag (via JavaScript in the first place. You have quotes around the name and id, but not the value.
 
reply
    Bookmark Topic Watch Topic
  • New Topic