bbunlock Posted November 1, 2008 Share Posted November 1, 2008 I have come accross a script suplied at w3schools (http://www.w3schools.com/PHP/php_ajax_database.asp) however I would like your help in modifying it to serve my purpose, below are the modifications I would like help with. 1, I would like to use standard links instead of a drop down form, so when a link is clicked it shows the results. 2, instead of sending just one paramater to the javascript code (value="?") I would like to send 2 paramaters in the link ("uid" and "up_type") 3, I would like it to display the first link details when page loads (so dont have to click a link to activate it on loadup) so by default the first link would be loaded on page load. If this was a standard link it would be somthing like the following "usrup.php?uid=some_id&up_type=some_type" its the "uid" and "up_type" that I need sent to the javascript code, the form only allows value="?" I need 2 paramaters sent. Unfortunately I have very little to no experience with javascript and ajax so your help would be greatly appriciated on this. There is no point me pasting the code for the form itself as im not looking to use a form/dropdown box but I will paste the javascript code used at w3schools. Javascript var xmlHttp function showUser(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="getuser.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } could someone please help me change this so that I can click a link instead of a form and the link supplies 2 paramaters to the javascript code instead of just the 1 thank you very much for your help regards wayne Quote Link to comment Share on other sites More sharing options...
php.ajax.coder Posted November 1, 2008 Share Posted November 1, 2008 <A HREF="javascript:showUser(this.value)">Click Here</A> This lets you use a link Quote Link to comment Share on other sites More sharing options...
bbunlock Posted November 2, 2008 Author Share Posted November 2, 2008 @php.ajax.coder thanks for the info, I was going to ask how to add the paramaters to that but did a little searching and found a few examples so managed to get it working great, even found out how to make it load the theme value when page is loaded. thanks for the help regards wayne Quote Link to comment Share on other sites More sharing options...
corbin Posted November 2, 2008 Share Posted November 2, 2008 HTML tags should be lower case by the way. Standards ftw. 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.