LeMen Posted November 22, 2013 Share Posted November 22, 2013 Hello. I am beginner try to learn something new. I have wish, "how to" below... 1. Let's say I have table within database which hold "ID" information. It's numeric, and I have input form. When the form is display, I have HTML code showing the "current" ID which is the last ID in the table, plus 1. So, if the last one is 12, then its shown 13, and soon. How I achieve this code to be done ? 2. I got table consist of "Name", "Address", "Age" I have option code, like this: <select name="nameID"> <option value="Mr. Alpha">Mr. Alpha</option> <option value="Mrs. Beta">Mrs. Beta</option> <option value="Ms. Gamma">Ms. Gamma</option></select> Upon user selected on of those option, I want to show the correspondent value within the database, which are "Address" and "Age", on the specific position within the form. How I done this purpose? Appreciate for your time and effort. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/284160-ajax-for-updating-info-on-the-page/ Share on other sites More sharing options...
Irate Posted November 22, 2013 Share Posted November 22, 2013 The associated event for selecting <option> tags is "onchange". Assuming you are using jQuery for Ajax purposes (you really should), you could do this. $("select[name='nameID']").on("change",function(){ var current = $(this).find("option:selected"); $.post("/scriptUrl.php",{val:current.attr("value")},function(d){ current.after(d); }); });Untested because I cannot test my code just yet on my phone (refer to my signature if you need to). Quote Link to comment https://forums.phpfreaks.com/topic/284160-ajax-for-updating-info-on-the-page/#findComment-1459592 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.