![]() |
jQuery - Adding new input boxes - 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 - Adding new input boxes (/showthread.php?tid=29005) |
jQuery - Adding new input boxes - El Forum - 03-27-2010 [eluser]Kemik[/eluser] Hi all, I've got a form where I want the user to be able to add new input boxes (one for description, one for price) so they can add items to an invoice. Here is the code I've got: Code: <scri.pt type="text/javascript"> Not having much luck making it add to the form. Any ideas? (obviously the [dots] are actually dots. jQuery - Adding new input boxes - El Forum - 03-27-2010 [eluser]markanderson993[/eluser] $(document).ready(function() { }); needs to contain ALL of your jQuery not just your event listeners. Hope this helps, Mark Anderson jQuery - Adding new input boxes - El Forum - 03-27-2010 [eluser]cahva[/eluser] [quote author="pianoman993" date="1269739679"]$(document).ready(function() { }); needs to contain ALL of your jQuery not just your event listeners. [/quote] Sorry but that is bullcrap ![]() The reason why it didnt work is how you did the append. In JS you cant create multiline variables like that. Instead you have to "glue" the lines together like this: Code: function addItem(){ jQuery - Adding new input boxes - El Forum - 03-27-2010 [eluser]sidscorner[/eluser] Like cahva said above, get rid of the linebreaks. If you had checked your console, you'd have seen an "unterminated string literal" error. jQuery - Adding new input boxes - El Forum - 03-27-2010 [eluser]sidscorner[/eluser] [quote author="pianoman993" date="1269739679"]$(document).ready(function() { }); needs to contain ALL of your jQuery not just your event listeners. Hope this helps, Mark Anderson[/quote] It is not necessary to put your functions inside $(document).ready() - only events you want to load as soon as the DOM is ready. jQuery - Adding new input boxes - El Forum - 10-27-2010 [eluser]anthrotech[/eluser] Okay...what is the most efficient way to do what you recommended? "Like cahva said above, get rid of the linebreaks." I have tried using the chr and preg_replace to no avail. How do you remove them? I need to do this with form_dropdown since it creates line breaks and messes up Javascript. jQuery - Adding new input boxes - El Forum - 10-27-2010 [eluser]danmontgomery[/eluser] http://forum.jquery.com/ jQuery - Adding new input boxes - El Forum - 10-27-2010 [eluser]anthrotech[/eluser] Thanks for the redirection...I figured it out. $dropdown_add_month = preg_replace("/\r?\n/", "\\n", $dropdown_add_month); It was a PHP question as relates to using a helper within Codeigniter, so I think it's most appropriate to ask the question here. Are you the moderator of this forum? May be you should let the moderator do their job. jQuery - Adding new input boxes - El Forum - 10-27-2010 [eluser]InsiteFX[/eluser] Are you the moderator of this forum? Do you see Moderator in his Title? May be you should let the moderator do their job. They do their job and very well. InsiteFX |