Jump to content

traxion

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by traxion

  1. traxion

    js and php

    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>
  2. i found i script on the web for my planning.i got a php array to a javascript array ut i dont get it in the ifstatmentCode:myarray = new Object(); myarray[1] = 5; myarray[2] = 5; myarray[3] = 5; myarray[4] = 4.5; myarray[5] = 5; myarray[6] = 4.5; myarray[7] = 5; myarray[8] = 5; myarray[9] = 5; myarray[10] = 5; myarray[11] = 6.5;obove is the arrayand i was hoping to read it out like this. the second statment is to check is the array works it does..Code: if (var i = 1 ;total == myarray[$i]; var i++) or if (total == myarray[5]) { totalCell.innerHTML = "<SPAN class='gelijk'> "+total+" </SPAN>"; } else { totalCell.innerHTML = "<SPAN class='ongelijk'> "+total+" </SPAN>"; }now i need to have the myarray [ variable ] so i can check the valuas but i cant make it varible plz help
  3. hey alli got a script of javascript function sum() { for (var col=0; col<numberOfCols; col++) { var total = sumCol(col); var totalCell = document.getElementById("total"+col); if (totalCell != null) { // Hier kun je de stijl van de totalen aanpassen document.write(total) if (total == <?php echo $a_uren[$z]; $z++?>) { totalCell.innerHTML = "<SPAN STYLE='background-color: #FF0000;'>"+total+"</SPAN>"; } else { totalCell.innerHTML = "<SPAN STYLE='background-color: : #000FFF;'>"+total+"</SPAN>"; } } } } i got the php array with some numbers 5 5 5 4.5 4.5 5 5 5 5 5 5 <= from my databaseand total is also made of some numbers 5 5 5 4.5 4.5 5 5 5 5 5 5 <= these numbers come from document.write(total)as u can see the numbers are the same but the code give @ both of the 4.5 's that it is incorrect.. i dont use javascript much so i think i made a mistake somewhere but where?i got a new problemi put the text in a cell of a table if the stament is correct or not that must change the background of the complete cell and not just only the background of the text
×
×
  • Create New...