• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Looping through Checkboxes

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to loop through checkbox and the once which are checked I will be extracting there values. Code what I have written is giving me multiple values for eg

Apple

Apple
Mango

Apple
Mango
Banana



but I want it to display in the form

Apple
Mango
Banana





Can someone tell me where I am going wrong.
 
Sheriff
Posts: 67752
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
Why on earth are you using eval()?

Also, without seeing the checkbox markup, it's hard to comment.
 
michell rosvlet
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is something wrong with EVAL
 
Bear Bibeault
Sheriff
Posts: 67752
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
If you aren't going to answer the questions, it's unlikely you'll get much help here.
 
michell rosvlet
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Voowww
I seriously don't understand what the problem with Eval is. Since I am trying to bring new value for J every time i want to evaluate that. If I don't put that it will not display me the value of check boxes I am trying to retrive
I am sure by removing that my code will not start working the way I want it.
 
Bear Bibeault
Sheriff
Posts: 67752
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
OK, since you'd rather not answer the questions that I need to know in order to make suggestions to help you, I cannot help you at this point.

eval() is like using a sledgehammer to crack walnuts. It's inefficient, unnecessary and just makes the code harder to read.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

michell rosvlet wrote:Voowww
I seriously don't understand what the problem with Eval is. Since I am trying to bring new value for J every time i want to evaluate that. If I don't put that it will not display me the value of check boxes I am trying to retrive
I am sure by removing that my code will not start working the way I want it.


Have you considered using a JavaScript library (like jQuery, Prototype, basically anything)?

In any case--the point is that eval is almost certainly not the solution you want, but without further information, it's tough to provide any alternatives.

Also, it's a dangerous habit to rely on JavaScript's semicolon insertion mechanism--I'd counsel against it.
 
michell rosvlet
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have not tried any of those you mentioned. I did remove EVAL after you and Bear Bibeault mentioned.
I know I am doing some mistake in looping. But not sure where I am going wrong.
 
michell rosvlet
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I don't use EVAL I am not able to read any values from Check box. It gives me a blank screen
 
Bear Bibeault
Sheriff
Posts: 67752
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
How can we help without seeing code?
 
michell rosvlet
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did post the code
 
Bear Bibeault
Sheriff
Posts: 67752
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
How is the old code going to help debug your new code?

Some friendly advice: making people jump through hoops to try and help you isn't exactly a winning strategy. I'd rethink your approach.

 
michell rosvlet
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to trouble you guys so much I was able to debug it.
Not sure what I was thinking when I added an extra For loop for count.
Sorry Guys. I am really Sorry. It is working now the way I wanted.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good deal--glad you figured it out!
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic