Jump to content

How do you change 2 ID's with one script


DBookatay

Recommended Posts

I have the following script which is attached to a <select> input, that updates a <div>

function getBody(yearId,makeId,modelId,trimId) {
var strURL="001/AJAX/Add/getBody.php?year="+yearId+"&make="+makeId+"&model="+modelId+"&trim="+trimId;
var req = getXMLHTTP();
if (req) {req.onreadystatechange = function() {if (req.readyState == 4) {if (req.status == 200) {document.getElementById('bodyHldr').innerHTML=req.responseText;}}}
	req.open("GET", strURL, true);
	req.send(null);
}
}

 

How do I make it so that when the script gets executed it loads 2 different pages into 2 different divs?

"001/AJAX/Add/getBody.php?" loads into "bodyHldr" and "001/AJAX/Add/getEngine.php?" loads into "engineHldr"

Link to comment
Share on other sites

I'm sure you figured this out by now, but if not try this.

 

What's coming down the pike and into "req.responseText" is a string. Seperate your two pages with a marker (like XXXXX) at the server and cut the req.responseText string into two stringone and stringtwo. Then

 

document.getElementById('bodyHldrONE').innerHTML=stringone;

 

document.getElementById('bodyHldrTWO').innerHTML=string two;

Link to comment
Share on other sites

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.