Jump to content

auto loading data from a selected value on page load php ajax db


chen2424

Recommended Posts

Hi guys,

 

ive used the this ajax db code tutorial from http://www.w3schools.com/php/php_ajax_database.asp and it works well. Problem is this, in the example, assuming we put <option selected value="1">Peter Griffin</option> , how do we get the page to load peter griffins data automatically?

 

If you observe when you enter the page, peter griffin is shown but not loaded. Youll have to select something else and go back to reselect peter grifin in order to load data. How can we autoload this on page load or refresh? Many thanks in adv to anyone who knows.

 

kind rgds, Chen

Hi,

Personally, if you have the id of the user on page load, I would get the data using php rather than using ajax.

Alternatively, you could call the javascript function on page load, passing it the id of the user:

 

eg. (where 1=id of user)

onload="showUser(1)"

 

Chris

Hi Cbolson.

 

thanks for yr reply , ive tried that,. :

<form>
Select a User:
<select name="users" onload="showUser(1)" onchange="showUser(this.value)">
<option selected value="1">Peter Griffin</option>

 

This doesnt solve the issue, peter still doesnt load on page load strangely,. any ideas why? Thanks in advance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.