markrumford Posted August 25, 2008 Share Posted August 25, 2008 Hi, I am getting a syntax error after the first js function runs. The error message is line: 2 char: 1 Syntax Error and I don't understand why. Could someone out there help me. The code is as follows; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Project Tree</title> <script language="JavaScript" type="text/javascript"> function getData(ReqStr) { var myReq; myReq=new ActiveXObject("Msxml2.XMLHTTP"); myReq.open("GET",ReqStr,false); myReq.send(null); response=myReq.responseText; return response; } function expSite(pNo, sNo) { var str; var aInHTML; str= "expandSite.php?"; str=str + "projectNo=" + pNo; str=str + "&siteNo=" + sNo; getData(str); areaArray = response.split(","); aInHTML=""; for (i=0; i<areaArray.length-1; i++) { aNo = i+1; aInHTML = aInHTML + " <div id='s" + sNo + "a" + aNo; aInHTML = aInHTML + "' class='area'><input id='expands" + sNo + "a" + aNo; aInHTML = aInHTML + "' class='expand' type='button' value='+'"; aInHTML = aInHTML + " onclick='expArea('"+pNo+"', '"+sNo+"', '"+aNo+"') />"; aInHTML = aInHTML + areaArray + " <br \/><\/div>"; } document.getElementById("s1").innerHTML=aInHTML; } function expArea(pNo, sNo, aNo) { var str; var aInHTML; str = "expandArea.php?"; str=str + "projectNo=" + pNo; str=str + "&siteNo=" + sNo; str=str + "&areaNo=" + aNo; alert(str); getData(str); unitArray = response.split(","); alert(unitArray.length); aInHTML = ""; aInHTML = aInHTML + " <div id='s" + sNo + "a" + aNo; + "' class='area'>"; aInHTML = aInHTML + " <input id='expands" + sNo + "a" + aNo + "'"; aInHTML = aInHTML + " class='expand' type='button' value='+'"; aInHTML = aInHTML + " onclick='expArea('A1XS', '"+sNo+"', '"+aNo+"')'>"; aInHTML = aInHTML + unitArray[0] + " <br \/>"; for (i=1; i<unitArray.length-1; i++) { uNo = i+1; aInHTML = aInHTML + "<div id='s" + sNo + "a" + aNo + "u" + uNo; aInHTML = aInHTML + "' class='area' >" + unitArray + "<br \/><\/div>"; } aInHTML = aInHTML + areaName + "<\/div>"; document.getElementById("s1a1").innerHTML=aInHTML; } </script> <style type="text/css"> #s1a1 {color: maroon;} .sites {margin-left:2ex;} .areas {margin-left:2ex;} .expand{height:3ex; font-size:xx-small; vertical-align:middle; line-height:40%;} </style> </head> <body> <div id="p1" class="project"> <input class="expand" value="+" type="button"> <?php projnum("A1XS") ?> <br /> <div class="sites"> <input class="expand" type="button" value="+" onclick="expSite('A1XS', '1')" /> <?php siteName("A1XS", "1") ?> <div id="s1" class="areas"> burble </div> </div> </div> </body> </html> <?php $cxn=""; function projnum($pNo) { global $cxn; dbcon(); $sql = "SELECT projectno FROM tbl_wbslvl1 "; $sql .= "WHERE projectno = '".$pNo."'"; $result = getres($cxn, $sql); $row = mysqli_fetch_row($result); echo $row[0]; } function siteName($pNo, $sNo) { global $cxn; dbcon(); $sql = "SELECT siteName FROM tbl_wbslvl2 "; $sql .= "WHERE projectno = '".$pNo."' "; $sql .= "AND siteNo = '".$sNo."'"; $result = getres($cxn, $sql); $row = mysqli_fetch_row($result); echo $row[0]; } function dbcon(){ global $cxn; $cxn = mysqli_connect("localhost","root","always","wbs"); if (!$cxn) die("Could not connect: " . mysql_error() ); } function getres($cxn,$sql){ $result = mysqli_query($cxn, $sql); if (!$result) echo "<h4>Error: ".mysqli_error($cxn)."</h4>"; elseif(@mysqli_num_rows($result) == 0){ echo "<h4>Query completed. No results returned.</h4>"; } else return $result; } ?> Thanks in advance Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 26, 2008 Share Posted August 26, 2008 Please your code. Quote Link to comment Share on other sites More sharing options...
markrumford Posted August 27, 2008 Author Share Posted August 27, 2008 Thanks I will in future, I have solved my problem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.