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
https://forums.phpfreaks.com/topic/228564-how-do-you-change-2-ids-with-one-script/
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;

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.