Petani Posted December 15, 2012 Share Posted December 15, 2012 hi friends, im trying a case, n i have problem on it, im gonna input multiple data , here sample my form html: <div id="form_name"> <select id="name_emp"> <option value="1234">joko</option> <option value="9900">Rudi</option> <option value="7786">anto</option> </select> <div id="id_emp"> </div> </div> <button id="addBtn">Add Name</button> n i want, for example, a user can show that select elemen above more than 1, so i create jquery code below: $("#addBtn").click(function() { $("#form_name").append('<select id="name_emp"><option value="1234">joko</option><option value="9900">Rudi</option> <option value="7786">anto</option> </select> <div id="id_emp"> </div>'); }); so, if a user click Add Name button, the select elemen wil show again. after a user choose from select elemen, i want jquery show the ID, example, if i choose joko, ID will show 1234 n so forth. so i create jquery code below: $('#name_emp').change(function() { var ID = $("#name_emp").val(); $('#id_emp').html(ID); }); it works when i choose the name n the ID is out between <div id="id_emp"></div> at first time, but, when i click Add Name button to show again the select elemen, n i choose employee name, the ID is not out,that's my problem friends, can you help me? thanks before.... Quote Link to comment https://forums.phpfreaks.com/topic/272023-get-multiple-data-from-append-jquery/ Share on other sites More sharing options...
codefossa Posted December 15, 2012 Share Posted December 15, 2012 You're reusing the ID? You can't do that. If you want to reset it, just select the option yourself in JS rather than rewrite it. You can also clear the HTML of the div if you want it gone instead of rewriting it. I could be way off, if so I'm sorry. I don't really understand what you're saying. Quote Link to comment https://forums.phpfreaks.com/topic/272023-get-multiple-data-from-append-jquery/#findComment-1399503 Share on other sites More sharing options...
Petani Posted December 15, 2012 Author Share Posted December 15, 2012 sorry, may be my explanation is poor, this is the form that id make: http://imageshack.us/photo/my-images/84/selectq.jpg/ Quote Link to comment https://forums.phpfreaks.com/topic/272023-get-multiple-data-from-append-jquery/#findComment-1399508 Share on other sites More sharing options...
Christian F. Posted December 15, 2012 Share Posted December 15, 2012 Please post either a link to the site, or the actual completed HTML code. A picture is of no help, as it doesn't say anything about the underlying code, and thus the problem. Quote Link to comment https://forums.phpfreaks.com/topic/272023-get-multiple-data-from-append-jquery/#findComment-1399511 Share on other sites More sharing options...
Petani Posted December 15, 2012 Author Share Posted December 15, 2012 okay, sorrt for that, this is my code friend, <html> <head> <script src="jquery.js"></script> <script> $(document).ready(function() { $("#addBtn").click(function() { $("#form_name").append('<select id="name_emp"><option value="1234">joko</option><option value="9900">Rudi</option><option value="7786">anto</option></select><div id="id_emp"></div>'); }); $('#name_emp').change(function() { var ID = $("#name_emp").val(); $('#id_emp').html(ID); }); }); </script> </head> <body> <div id="form_name"> <select id="name_emp"> <option value="1234">joko</option> <option value="9900">Rudi</option> <option value="7786">anto</option> </select> <div id="id_emp"> </div> </div> <button id="addBtn">Add Name</button> </body> </html> - when i select employee's name, the ID's employee is out, -after that, i click Add Name button to display that select element again, so that i could choose more employee.. -then i choose the employee's name again, but ID's employee is not out that's my problem friends, Quote Link to comment https://forums.phpfreaks.com/topic/272023-get-multiple-data-from-append-jquery/#findComment-1399513 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.