chen2424 Posted October 25, 2009 Share Posted October 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
cbolson Posted October 25, 2009 Share Posted October 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
chen2424 Posted October 25, 2009 Author Share Posted October 25, 2009 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! Quote Link to comment Share on other sites More sharing options...
cbolson Posted October 25, 2009 Share Posted October 25, 2009 you need to add it to the page load (eg in the <body> tag). Quote Link to comment Share on other sites More sharing options...
chen2424 Posted October 25, 2009 Author Share Posted October 25, 2009 Cheers Cbolson! it works great! Quote Link to comment 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.