![]() |
jQuery Form Input Loop [solved] - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: jQuery Form Input Loop [solved] (/showthread.php?tid=8155) |
jQuery Form Input Loop [solved] - El Forum - 05-07-2008 [eluser]Chris Newton[/eluser] Code: var preset_0= new Array(); Need a little jQuery help, if anyone out there would be so kind. When I make a selection (change) to #preset (which is a drop down with values like 'preset_0 => "Choice 1"') I'd like to fill input fields with the associated array data. With PHP, I'd just use a foreach loop, but I'm not good enough with jQuery to figure out how to do the same. For each array item, I'd like to fill an input field with the same key (input_field_0, input_field_1, input_field_2) from the selected array. Is that clear? Am I talkin crazy talk? If I was just going to update 1 field, I know how to do that, just can't figure out the rest. jQuery Form Input Loop [solved] - El Forum - 05-07-2008 [eluser]xwero[/eluser] jQuery has for you the each method that does the same as the foreach loop in php5 meaning you can iterate arrays and objects. jQuery Form Input Loop [solved] - El Forum - 05-07-2008 [eluser]Chris Newton[/eluser] Ah!!! I've seen that before, but couldn't remember. Thanks Xwero... you're always a font of knowledge. I may have some follow up questions, but I'll try to work out what I can. jQuery Form Input Loop [solved] - El Forum - 05-08-2008 [eluser]Chris Newton[/eluser] For anyone that stumbles on this, this is the code that worked: Code: $("#presets").change(function() { |