ask21900 Posted February 23, 2010 Share Posted February 23, 2010 My javascript experience is a little limited so I was hoping someone can help me out... I have a form that is inserted into mysql by sending the data to a php script via ajax. The php script will return data to populate the div. I would then like to use a portion of the returned data to populate a second form on the page. Thanks in advance for all your help! Quote Link to comment Share on other sites More sharing options...
trq Posted February 23, 2010 Share Posted February 23, 2010 Code? Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted February 23, 2010 Share Posted February 23, 2010 I'll guess that what you want to do is use the returned php to change some html right? Just put something like this in the function you call onreadystatechange if (http.readyState == 4) { var result=http.responseText; document.getElementById('SomeDivOrSomething').innerHTML=result; } Quote Link to comment Share on other sites More sharing options...
ask21900 Posted February 23, 2010 Author Share Posted February 23, 2010 Code? I haven't wrote the code yet because I want to make sure I can do what I want it to before writing it, but here is some (very) rough pseudo code: //Upon initial load open first div form1 start textbox1.1 textbox1.2 submit close first div //after ajax call open first div display userId generated by php and returned by ajax display the data from form1 as returned by ajax display additional data supplied by php/ajax close first div open second div form2 start textbox2.1 //should be equal to the userId generated by php above textbox2.2 textbox2.3 submit form2 close second div I'll guess that what you want to do is use the returned php to change some html right? Just put something like this in the function you call onreadystatechange if (http.readyState == 4) { var result=http.responseText; document.getElementById('SomeDivOrSomething').innerHTML=result; } Assigning the value to form2>textbox1 would work using the .value attribute, but if at all possible, I would like to do this without modifying my ajax function since I use it for hundreds of pages already. If it is necessary to use this method, I can duplicate my ajax function and make the mods just for this page, but I would rather not. Maybe I am going about this the wrong way... is there a way to modify the url/post data of a page using ajax (without refreshing)? For instance, can I just write the data in form1 to the url (in addition to the ajax get) so that it can be used by php during the scripting of form2? 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.