Jump to content

Urgent help, please.


giv3mesmile

Recommended Posts

In my site, i have FAQ, and answers...i imaginated it....

there are two boxes, one witch is constant and includes questions, and the other that will display the answer ( Right one in the image )

So, what I need is, when user clicks on the question ( left side on the image ), the answer text popup in the right box...

any clues of how to do it?

I've asked this before , but didnt get a propper answer, and i really need it now :(

thanks in advanced...

 

[attachment deleted by admin]

Link to comment
Share on other sites

  • 2 weeks later...

Well, this you would want to do in javascript probably...  The easiest and most simple way would be to use PHP to query a mySQL database to get the answer for the specific question clicked...

 

Then in the link you would put like:

 

OnClick="GetQuestion('fetch.php?id=1') return false;"

 

Then of course you would have your right side with a div or something along those lines with an ID in it for javascript to read and modify the innerHTML of.

 

And of course creating the fetch.php to fetch the information from the mySQL database.

 

hope it gets you on your way...

 

Just to help get you started, I wrote your javascript ajax calls for you.

 

function AjaxObjectCreateGeneral()
{
var req;  // The variable that makes Ajax possible!

try{
	// Opera 8.0+, Firefox, Safari
	req = new XMLHttpRequest();
} catch (e){
	// Internet Explorer Browsers
	try{
		req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try{
			req = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e){
			// Something went wrong
			alert("Your browser broke!");
			return false;
		}
	}
}

return req;
}

function changeAnswer(url) {
req=AjaxObjectCreateGeneral(); 
	if(req) { 
		var myRand = parseInt(Math.random()*99999999);
		var url = url;
		var srcs = url+"&int="+myRand;
		$('TransMsgDisplay').innerHTML='Querying Database';
		req.onreadystatechange = processFetch;
		req.open("GET",srcs,true);
		req.send();
	} 
}

function processFetch()
{
if(req.readyState == 4) 
{
	if(req.status == 200) 
	{  
	if(req.responseText == 0) {
		document.location.href="index.php";
	} else {
		document.getElementById("TransMsgDisplay").innerHTML=req.responseText;
	}

	}
}

}

 

This would either be directly in the HTML page, or added in from a seperate file.

 

Again hope it helps you on your way.

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.