Jump to content

Recommended Posts

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. :)

Link to comment
https://forums.phpfreaks.com/topic/284160-ajax-for-updating-info-on-the-page/
Share on other sites

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).
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.