Jump to content

js and php


traxion

Recommended Posts

i got several files.. projecten.php, projecten.incl.php and selectuser.js and some more but u dont need them for the problemtrue AJAX i get a variable "q" (in projecten.incl.php and he shows every think i want to see that works great now i want from another file to call the ajax (go to a new page with a link) and i send a GET with it.. now im looking for somethink in js (or anther code) where i can get my GET variable from php to the selectuser.js file (he calls ajax). the probleem is i want to have done that compleetly automatic.. and i dont now howi hope u get the problem.. else just aski will post the code below.. i hope u can find what i need to changeselectuser.js

var xmlHttpfunction showUser(str){	xmlHttp=GetXmlHttpObject()	if (xmlHttp==null)	 {		 alert ("Browser does not support HTTP Request")		 return	 }	var url="includes/projecten.incl.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;	}

projecten.incl.php

<?php	 $project = $_GET['q'];  ?>	<table border="0" >		<tr>			<td valign="top">				<?php include "projecten.project.php"; ?><br><br>				<?php	 include "projecten.fase.php";	?>			</td >				   			<td valign="top">		</td>	   			<td valign="top">				<?php include "projecten.opmerking.php"; ?>			</td>	   		</tr>	</table>   <?php	if ( $project !== "")		{			echo "<p>In de toekomst komen hier meerdere opties voor het project bij.</p>";		}	else {echo "<p>Selecteer een project</p>";}?>

projecten.php

<!doctype html public "-//W3C//DTD HTML 4.0 //EN"><html><head><script src="selectuser.js"></script><LINK HREF="includes/stijl.css" REL="stylesheet" TYPE="text/css" MEDIA="screen, print">	   <title>Projecten</title><script LANGUAGE="JavaScript"><!-- Beginfunction popUp(URL) {day = new Date();id = day.getTime();eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=220,left = 490,top = 362');");}// End --></script></head><body><h3>Projecten</h3><br>  <?php$project = $_GET['project'];$budget = $_GET['budget']; if	 ( $_GET['date2'] == "" )		{$date = $_GET['date'];} else	 {$date = $_GET['date2'];}?>	<form method="get" action="projecten.php">	<select name="project" onchange="showUser(this.value)">	<option value="">Maak uw keuze</option><?php			 	include "includes/connect_weekbrief.php";						$query = "			SELECT DISTINCT (projectuser.code) as code			FROM projectuser			WHERE	 projectuser.user = 'planner'			AND projectuser.id > '100'			ORDER BY projectuser.code asc			";   	$sql = mysql_query($query) or die ( mysql_error( ) );	   	while($record = mysql_fetch_object($sql))	 {	   				$project_code = "$record->code";				  // project_code aanmaken	echo "<option value=". $project_code .">Project: ".$project_code."</option>"; // alles neerzetten											}   	echo "</select></form>";	echo "<p><div id=\"txtHint\">Hier zal informatie over het project komen.</div></p>";?></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...