Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jQuery - For Loop question

 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day,

I have an array('checkComponents ') which holding list of textbox input id, and i want to iterate it to get the user value that have been type but seem i didn't get my luck on it.



question : how to used jQuery to get user input value from an array that holding input component id?

Appreciated your help on this !
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd use jQuery.map().
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear and that's a good function, here is what i try but i get the value of "undefine"

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not forming the selector correctly from the id values.

Also, alert is a dinosaur. At least open a JavaScript console and use console.log().
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear for the clue
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one extra question Bear, if we using console.log() , is it compatible to all browser and it won't caused any exception ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nakataa Kokuyo wrote:one extra question Bear, if we using console.log() , is it compatible to all browser and it won't caused any exception ?

It's not something that you'd leave in your code, just like you wouldn't leave in any debug alerts.

All modern browsers support some sort of JavaScript console, but a reference to console can fail if it's disabled (which it will be for most users).
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Bear, is there a chance to turn on the console automatically if it was off (probably from code call) ? the debug message is somehow useful when complicated JS function applied.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.

Would you really want the JavaScript console to pop open on a user whenever they visit your page?
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
make sense Bear , thanks again !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic