SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 33
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to pass a variable from encapsulated function

    Hallo, in the following code I am trying to pass the return value of the function "getrownum" to the PHP code...but the problem is, when i am trying to pass the return value of the forementioned function, i got no result..Please help and guid me.."please find my attempts highlighted below in red"
    Code:
    ..
    ...
    ..
    var arr;
    var num;
    
    function setrownum(par)
    {
     num=par;
    }
    
    function getrownum()
    {
    return num;
    }
    
    function cell()
    	{
    		var x=document.getElementById('Table2').rows[1].cells;
    		alert(x[9].innerHTML);
    var tableElem=document.getElementById('Table2').getElementsByTagName('tr');
    		var numofRows=tableElem.length;
    		alert('Your table has ' + numofRows + ' rows.');
    		
     
     
    		for (i = 0; i < tableElem.length; i++) {
            tableElem[i].onclick = function() {
                alert(this.rowIndex + 1);
    			par=this.rowIndex+1;
    			setrownum(par);
    	     
    	}
    	alert(num);	
        }
            	alert(getrownum());}

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bit of an incomplete picture ... but

    1) The function cell is setting up all the click events. I am assuming that is called from an onload event. Is that so?

    If it isn't then make sure it is called after the table has been defined.

    2) "PHP code" suggests that you want num passed back to the server. If that is the case then num must be moved to an input field so it is sent to the server as part of the form data. Are you doing this.

    3) You have a number of alerts. They should be telling you everything is working as you would expect. If this is not the case when does it not.

  3. #3
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    d
    Quote Originally Posted by PhilipToop View Post
    Bit of an incomplete picture ... but

    1) The function cell is setting up all the click events. I am assuming that is called from an onload event. Is that so?
    yes
    If it isn't then make sure it is called after the table has been defined.

    2) "PHP code" suggests that you want num passed back to the server. If that is the case then num must be moved to an input field so it is sent to the server as part of the form data. Are you doing this.
    no, i want to pass the return value from function cell to the PHP code so that I can use this value to index an array.3) You have a number of alerts. They should be telling you everything is working as you would expect. If this is not the case when does it not.

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The javascript runs in the browser. The PHP code runs on the server. You have to pass the javascript variable num to the PHP code on the server. There are two ways of doing this.

    1. move to page which has url that includes the value of num. For example

    http://mysite.com/code.php?5

    or better (because it is extendible in a flexable way)

    http://mysite.com/code.php?num=5

    In both case the php code, code.php, can pick up the value.

    2. Include a form in your html which has a input field to hold the value of num and then submit the form

    Code HTML4Strict:
    <form action="" method="post">
    <input type="hidden" name="num" value="" />
    </form>

  5. #5
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hallo guys, please find below my javascript and embedded PHP code...my propblem is:
    1-i want to gain access to a variable should be returned from an encapsulated function, this function called is "getrownum" and it is in javascript code and below the function is highlighted in green

    2- after having access to this varialbe from the forementioned function "getrownum", i want to pass this variable to the PHP code "highlighted in red" so that i can use this variable as an index of an array of rows returned from the sql_fetch_row, in other words:
    Code JavaScript:
     
    $query2 = "SELECT ObjectID FROM $table where FamilyName='$field4' and FirstName='$field5'";
    $test=mysql_query($query2);
    while ($array2 = mysql_fetch_row($test)) 
    {
     $array2[?>    <SCRIPT LANGUAGE='javascript'> [COLOR="Red"]getrownum()[/COLOR];</SCRIPT> ];
     }
    echo "</tr>";
     }

    3- please find below the complete code:
    Code JavaScript:
    <html>
    <head>
       <!-- Script Sources-->
        <link rel="stylesheet" type="text/css" href="styles.css" />
        <style type="text/css">
        <!--@import url("styles.css")-->
        </style>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=DioG219lPJG3WTn3zmQqebsjVg" type="text/javascript"></script>
        <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>
        <script type="text/javascript">
          var gmap = null;
          var findTask = null;
          var params = null;
          var mapExtension = null;
          var gOverlays = null;
          var gOverlays1 = null;
          var bounds = null;
          var posLatLng = null;
     
     
    	function initialize() {
            // GMap construction
            gmap = new GMap2(document.getElementById('gmap'));
    	gmap.setCenter(new GLatLng(48.539444, 18.566389), 13); //Velke Pole
            gmap.enableScrollWheelZoom();
    	gmap.setMapType(G_HYBRID_MAP);
    	gmap.addControl(new GLargeMapControl3D());
    	gmap.addControl(new GMapTypeControl());
    	gmap.enableScrollWheelZoom();
     
     
    	// Set the min and max scale for each layer
    	bounds = gmap.getBounds();
    	var minMapScale = 11;
    	var maxMapScale = 19;
    	// get array of map types
    	var mapTypes = gmap.getMapTypes();
    	// overwrite the getMinimumResolution() and getMaximumResolution() methods for each map type
    		for (var i=0; i<mapTypes.length; i++) {
    			mapTypes[i].getMinimumResolution = function() {return minMapScale;}
    			mapTypes[i].getMaximumResolution = function() {return maxMapScale;}
    		}
    		//Create MapExtension utility class
    		mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);
     
     
           // Find Task
            findTask = new esri.arcgis.gmaps.FindTask("http://g-ags93.hs-karlsruhe.de/ArcGIS/rest/services/slovakei/0617final_WGS/MapServer");
     
    	}
        //Function for find
    	function executeFind(searchText){
    	// Find Parameters
    		 params = new esri.arcgis.gmaps.FindParameters();
    		 params.layerIds = [1];
     
    		 var qYear = document.getElementById("qYear").value;
     
    		 if  (qYear == "1")
    		 	params.searchFields = ["HsNr1850"];
    		else if(qYear == "2")
    			params.searchFields = ["HsNr1925"];
    		else
    			alert("Please Select a Year for Query")
     
     
    		// clear map overlays and event listeners using MapExtension removeFromMap
    		mapExtension.removeFromMap(gOverlays);
     
    		// set find parameters
    		params.contains = false;
    		params.searchText = searchText;;
     
    		// execute find task
    		findTask.execute(params, findCompleteCallback);
    	}
     
     
    	//Function for Find function results (zoom to and info window)  
    	function findCompleteCallback(response) {
            	var house = response.findResults[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResults]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
     
    		var houseGeometry = house.feature.geometry[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResult]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.Feature]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// Feature.geometry is an array of GPolygon objects because, Hawaii for example is an ArcGIS Polygon that has multiple rings --
    		// where each ring is represented as a GPolygon object in Google Maps API
     
    		var infoWindowOptions1 = {
    			contentTabs: [{label:"Building", content: "<b><p>House Number 1850:  </b>{HsNr1850}<br/> <b>Owner:  </b>{owner}<br/><b>Usage:  </b>{house_usag}<br/>"},
    			{label:"Other", content:"<br/><b>House Number 1925:  </b>{HsNr1925}"}
    			],
    			selectedTab:0
    		};
     
    		// center and zoom to the result
    		var polygonBounds = houseGeometry.getBounds();
    		// GPolygon.getBounds method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GPolygon]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var zoomLevel = gmap.getBoundsZoomLevel(polygonBounds);
    		// GMap2.getBoundsZoomLevel method
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GMap2]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var polygonCenter = polygonBounds.getCenter();
    		// GLatLngBounds.getCenter method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GLatLngBounds]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		gmap.setCenter(polygonCenter, zoomLevel);
     
    		// add the findresutls to google map without any style
    		gOverlays = mapExtension.addToMap(house, null, infoWindowOptions1);
          }
     
     
    	function ChangeColor(tableRow, highLight)
    	{
    		if (highLight)
    		{
    		tableRow.style.backgroundColor = '#7496C2';
    		}
    		else
    		{
    		tableRow.style.backgroundColor = 'white';
    		}
    	}
    [COLOR="SeaGreen"][B]var arr;
    var num;
     
    function setrownum(par)
    {
     num=par;
    }
     
    function getrownum()
    {
    return num;
    }
     
     
     
    function cell()
    	{
    		var x=document.getElementById('Table2').rows[1].cells;
    		alert(x[9].innerHTML);
    		var tableElem = document.getElementById('Table2').getElementsByTagName('tr');
    		var numofRows=tableElem.length;
    		alert('Your table has ' + numofRows + ' rows.');
     
     
     
    		for (i = 0; i < tableElem.length; i++) {
            tableElem[i].onclick = function() {
                alert(this.rowIndex + 1);
    			par=this.rowIndex+1;
    			setrownum(par);
     
    	}
     
        }
            alert(num);
    	alert(getrownum());
    }[/B][/COLOR] 
     
      </script>
     
     
    </head>
     
     
    <body onload="initialize">
     
    <div id ="logoCont" style="background-color: #7496C2;">
    	<div class = "headline">Cultural Heritage Map of Velk&eacute; Pole, Slovakia
     
    	</div>
    </div>
     
    <div id="topRightCont" class = "content" style="width: 415px;"><h1>Enter in Last and First Name</h1> 
    	<form action="phpProject6Formate.php" method="post">
     
    	Family Name:<input type="text" name="field4"><br>
    	First Name:<input type="text" name="field5"><br>
     
    	<input type="Submit">
     
    <div id = "credit" style="position:absolute;top: 817px;">
    	<table>
    	<tr>
    		<td style="vertical-align:top;">
    		<div class = "quicklinks" >
    		&copy; Hochschule Karlsruhe - Technik und Wirtschaft 2009, <a href="impressum.html">Impressum</a>
    		</div>
    		</td>
    		<td style="vertical-align:top;width:15px;">
    		</td>  
    		<td style= "width:225px;">
    		<a href="http://www.daad.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/daad.gif" width="179" height="13" border="0"></a>
    		<a href="http://www.asiin.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/asiin_klein.jpg" width="100" height="53" border="0" vertical-align="bottom" align="left"></a> 
    		<a href="http://www.facebook.com/pages/Fakult%C3%A4t-f%C3%BCr-Geomatik-Hochschule-Karlsruhe/166116110093298"><img src="http://www.g.hs-karlsruhe.de/geo/bilder_neue/facebook-logo.png" width="100" height="38" border="0" align = "right" vertical-align="bottom"></a>
    		</td>
    	</tr> 
    	</table>
          </div>	
     
    </form>
     
     
    </div>
     
     
    <div id="navcontainer" style="position: absolute; top: 185px; left: 15px; width: 815px; height:25px;">
    <ul id="navlist">
    <li id="active">
    	<li><a href="HomePage.html">Home</a></li>
    	<li><a href="Map.html">Map</a></li>
    	<li><a href="History.html">History</a></li>
    	<li><a href="About.html">About</a></li>
    </ul>
    </div>
     
     
     
    <div style="position:absolute; top: 208px; left: 15px; width: 810px; height:500px; overflow:auto; border-style:solid;border-width:3px;border-color:#7496C2">
    <?php
     
    $username="gisPrj6@localhost";/*g-ags93*/
    $password="$****";
    $database="sl6ova67";
     
     
     
    $field4=$_POST['field4'];
    $field5=$_POST['field5'];
     
     
     
    $link =mysql_connect(localhost,'gisPrj6','$****');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    echo '';
    mysql_select_db($database) or die( "Unable to select database");
     
     
    $table = 'eventtable';
     
     
    if (empty($field5)) {
        /*echo 'FirstName is either 0, empty, or not set at all';*/
        $query = "SELECT * FROM $table where FamilyName='$field4'";/*Year,Date,FamilyName,FirstName,EventType,AgeSpouse*/
    }
    else
    {
      $query = "SELECT * FROM $table where FamilyName='$field4' and FirstName='$field5'";
    }
     
     
    if (!$sth = mysql_query($query)) {
       die("Ausführen der Abfrage <b>$query</b> nicht möglich: ".mysql_error()."\n");
    } 
    /*else {
       echo "Ausführen der Abfrage <b>$query</b> war erfolgreich.\n<br />\n";
    }*/
     
    echo "<table border='1' cellpadding='2' cellspacing='0' width='790px'><tr>";
     
     
    /*echo "Table: <b>$table</b><br />\n";*/
    for ($i = 0; $i < mysql_num_fields($sth); $i++) {
       $col = mysql_field_name($sth,$i);
     
       echo "<td width='13%'> <b>$col&nbsp;&nbsp;</b> </td>";
    }
    echo "</tr></table>";
     
     
     
     
    echo "<table id='Table2' border='1' cellpadding='2' cellspacing='1' width='790px' height='300px'>";
     
     
     
     
    [COLOR="Red"][B]while ($array = mysql_fetch_row($sth)) {
    echo "<tr onmouseover='ChangeColor(this, true);' 
                  onmouseout='ChangeColor(this, false);' 
                  onclick='cell();'>";
       foreach ($array as $col) {
          echo "<td width='13%'>$col&nbsp;&nbsp;&nbsp;</td>";
       }[/B][/COLOR]echo "</tr>";
     
    }
    echo "</table>";
     
    [COLOR="Red"][B]$query2 = "SELECT ObjectID FROM $table where FamilyName='$field4' and FirstName='$field5'";
    $test=mysql_query($query2);
     
     
    while ($array2 = mysql_fetch_row($test)) {
     
    	  $array2[?>    <SCRIPT LANGUAGE='javascript'> getrownum();</SCRIPT> <?php ];
       }
    echo "</tr>";
     
    }
    echo "$objID";[/B][/COLOR]mysql_free_result($sth);
     
    ?>
    </div>
     
     
    <div id="gmap"  style="position:absolute; top: 208px; left: 915px; width: 810px; height:500px; overflow:auto; border-style:solid;border-width:3px;border-color:#7496C2">
     
    </div>
    </body>
    </html>

    Note: i have a sharp deadline on 22/7 and this problem prevent me from proceeding...all your attempts are highly appreciated.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Elpharaoh View Post
    after having access to this varialbe from the forementioned function "getrownum", i want to pass this variable to the PHP code
    • PHP code only runs on the server.
    • The server sends the web page to the client.
    • The client then processes the web page, and runs the JavaScript code.


    If you want JavaScript code to send information to the PHP code, you can do that by placing the PHP code in a separate file so that the HTML page can then request that PHP file with the appropriate JavaScript-based information.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This code has

    Code PHP:
    echo "<tr onmouseover='ChangeColor(this, true);' 
                  onmouseout='ChangeColor(this, false);' 
                  onclick='cell();'>";
       foreach ($array as $col) {
          echo "<td width='13%'>$col&nbsp;&nbsp;&nbsp;</td>";
       }[/B][/COLOR]echo "</tr>";
     
    }

    Code JavaScript:
     onclick='cell();

    Cell is your function for initialisation - it sets up event handles for click event on the table rows. So onclick is not needed. cell should be called from your initialize function.

    To return the value to num you have to do as I explain before.

    2. Include a form in your html which has a input field to hold the value of num and then submit the form

    Code HTML4Strict:
    <form action="" method="post">
    <input type="hidden" name="num" value="" />
    </form>

  8. #8
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looking further - you already have a form in your html

    Code HTML4Strict:
        <form action="phpProject6Formate.php" method="post">
     
        Family Name:<input type="text" name="field4"><br>
        First Name:<input type="text" name="field5"><br>
     
        <input type="Submit">

    This can be extended with

    Code HTML4Strict:
    <input type="hidden" id="idnum" name="num" value="" />

    which can be populate from setrownum

    Code JavaScript:
    function setrownum(par)
    {
     document.getElementById('idnum').value = par;
     num=par;
    }

    On the php script you are already picking up form variables

    Code PHP:
    $field4=$_POST['field4'];
    $field5=$_POST['field5'];

    or extend it to pick up the num

    Code PHP:
    $field4=$_POST['num'];

    This can then be used latter where you currently have the javascript nonsense.

    Code PHP:
    $query2 = "SELECT ObjectID FROM $table where FamilyName='$field4' and FirstName='$field5'";
    $test=mysql_query($query2);
     
     
    while ($array2 = mysql_fetch_row($test)) {
     
          $array2[$num];
       }
    echo "</tr>";
     
    }

  9. #9
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Guys,
    many thanks for all of you.....
    and sorry for the late reply...actually i have nt started implementing what have u advised me yet ..because I have tomorrow an final exam and after tomorrow i have the last 2 final exams...so after tomorrowi have to start implementing these techniques..
    your contributions in providing me ways to solve my problem are really highly appreciated..pray for me to pass the exams

    ciao

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Elpharaoh View Post
    pray for me to pass the exams
    As a rationalist I will go one better, and wish that you are studying hard for your exams.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #11
    SitePoint Member
    Join Date
    Nov 2008
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AJAX will do this. You can pass the value to a PHP script on the server and have it process directly. AJAX is the only way to do what you want.

    Research jquery ajax... clean, easy and direct.

  12. #12
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    As a rationalist I will go one better, and wish that you are studying hard for your exams.
    thanks, i would never have thought that praying will replace the diligence...
    i'm also rationalist

  13. #13
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,
    i have tried what you have recommended.. but i still, after passing the variable from javascript to php, i cant see the variable contents in php, although, this variable i can access its contents in javascript..

    Code JavaScript:
    <html>
    <head>
       <!-- Script Sources-->
        <link rel="stylesheet" type="text/css" href="styles.css" />
        <style type="text/css">
        <!--@import url("styles.css")-->
        </style>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=DioG219lPJG3WTn3zmQqebsjVg" type="text/javascript"></script>
        <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>
        <script type="text/javascript">
     
     
     
          var gmap = null;
          var findTask = null;
          var params = null;
          var mapExtension = null;
          var gOverlays = null;
          var gOverlays1 = null;
          var bounds = null;
          var posLatLng = null;
     
     
    	function initialize() {
            // GMap construction
            gmap = new GMap2(document.getElementById('gmap'));
    	gmap.setCenter(new GLatLng(48.539444, 18.566389), 13); //Velke Pole
            gmap.enableScrollWheelZoom();
    	gmap.setMapType(G_HYBRID_MAP);
    	gmap.addControl(new GLargeMapControl3D());
    	gmap.addControl(new GMapTypeControl());
    	gmap.enableScrollWheelZoom();
     
     
    	// Set the min and max scale for each layer
    	bounds = gmap.getBounds();
    	var minMapScale = 11;
    	var maxMapScale = 19;
     
    	// get array of map types
    	var mapTypes = gmap.getMapTypes();
    	//Create MapExtension utility class
    	mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);
     
     
           // Find Task
            findTask = new esri.arcgis.gmaps.FindTask("http://g-ags93.hs-karlsruhe.de/ArcGIS/rest/services/slovakei/0617final_WGS/MapServer");
     cell();
    	}
        //Function for find
    	function executeFind(searchText){
    	// Find Parameters
    		 params = new esri.arcgis.gmaps.FindParameters();
    		 params.layerIds = [1];
     
    		 var qYear = document.getElementById("qYear").value;
     
    		 	params.searchFields = ["ObjectID"];
     
    		// clear map overlays and event listeners using MapExtension removeFromMap
    		mapExtension.removeFromMap(gOverlays);
     
    		// set find parameters
    		params.contains = false;
    		params.searchText = searchText;;
     
    		// execute find task
    		findTask.execute(params, findCompleteCallback);
    	}
     
     
    	//Function for Find function results (zoom to and info window)  
    	function findCompleteCallback(response) {
            	var house = response.findResults[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResults]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
     
    		var houseGeometry = house.feature.geometry[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResult]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.Feature]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// Feature.geometry is an array of GPolygon objects because, Hawaii for example is an ArcGIS Polygon that has multiple rings --
    		// where each ring is represented as a GPolygon object in Google Maps API
     
    		var infoWindowOptions1 = {
    			contentTabs: [{label:"Building", content: "<b><p>House Number 1850:  </b>{HsNr1850}<br/> <b>Owner:  </b>{owner}<br/><b>Usage:  </b>{house_usag}<br/>"},
    			{label:"Other", content:"<br/><b>House Number 1925:  </b>{HsNr1925}"}
    			],
    			selectedTab:0
    		};
     
    		// center and zoom to the result
    		var polygonBounds = houseGeometry.getBounds();
    		// GPolygon.getBounds method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GPolygon]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var zoomLevel = gmap.getBoundsZoomLevel(polygonBounds);
    		// GMap2.getBoundsZoomLevel method
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GMap2]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var polygonCenter = polygonBounds.getCenter();
    		// GLatLngBounds.getCenter method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GLatLngBounds]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		gmap.setCenter(polygonCenter, zoomLevel);
     
    		// add the findresutls to google map without any style
    		gOverlays = mapExtension.addToMap(house, null, infoWindowOptions1);
          }
     
     
    	function ChangeColor(tableRow, highLight)
    	{
    		if (highLight)
    		{
    		tableRow.style.backgroundColor = '#7496C2';
    		}
    		else
    		{
    		tableRow.style.backgroundColor = 'white';
    		}
    	}
     
    [COLOR="red"][SIZE="5"]var num;
     
    function setrownum(par)
    {
     document.getElementById('idnum').value = par;
     num=par;
     
    }
    function  getrownum()
    {
    return num;
    }
    	function cell(){
    		var tableElem = document.getElementById('Table2').getElementsByTagName('tr');
    		for (i = 0; i < tableElem.length; i++) {
    			tableElem[i].onclick = function() {
    				alert(this.rowIndex + 1);
    			par=this.rowIndex+1;
    			setrownum(par);
    		        alert(getrownum()*10);
     
    				}
     
    		}
     
    	alert(num*100);
      	}[/SIZE][/COLOR]	
      </script>
     
     
    </head>
     
     
    <body onload="initialize()">
     
    <div id ="logoCont" style="background-color: #7496C2;">
    	<div class = "headline">Cultural Heritage Map of Velk&eacute; Pole, Slovakia
     
    	</div>
    </div>
     
    <div id="topRightCont" class = "content" style="width: 415px;"><h1>Enter in Last and First Name</h1> 
    	<form action="thisBackUpphpProject6Formate.php" method="post">
     
    	Family Name:<input type="text" name="field4"><br>
    	First Name:<input type="text" name="field5"><br>
               hidden: <input type="text" id="idnum" name="num" value=""><br>
    	<input type="Submit">
     
    <div id = "credit" style="position:absolute;top: 817px;">
    	<table>
    	<tr>
    		<td style="vertical-align:top;">
    		<div class = "quicklinks" >
    		&copy; Hochschule Karlsruhe - Technik und Wirtschaft 2009, <a href="impressum.html">Impressum</a>
    		</div>
    		</td>
    		<td style="vertical-align:top;width:15px;">
    		</td>  
    		<td style= "width:225px;">
    		<a href="http://www.daad.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/daad.gif" width="179" height="13" border="0"></a>
    		<a href="http://www.asiin.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/asiin_klein.jpg" width="100" height="53" border="0" vertical-align="bottom" align="left"></a> 
    		<a href="http://www.facebook.com/pages/Fakult%C3%A4t-f%C3%BCr-Geomatik-Hochschule-Karlsruhe/166116110093298"><img src="http://www.g.hs-karlsruhe.de/geo/bilder_neue/facebook-logo.png" width="100" height="38" border="0" align = "right" vertical-align="bottom"></a>
    		</td>
    	</tr> 
    	</table>
          </div>	
     
    </form>
     
     
    </div>
     
     
    <div id="navcontainer" style="position: absolute; top: 185px; left: 15px; width: 815px; height:25px;">
    <ul id="navlist">
    <li id="active">
    	<li><a href="HomePage.html">Home</a></li>
    	<li><a href="Map.html">Map</a></li>
    	<li><a href="History.html">History</a></li>
    	<li><a href="About.html">About</a></li>
    </ul>
    </div>
     
     
     
    <div style="position:absolute; top: 208px; left: 15px; width: 810px; height:500px; overflow:auto; border-style:solid;border-width:3px;border-color:#7496C2">
    <?php
     
    $username="gisPrj6@localhost";/*g-ags93*/
    $password="$l34f45";
    $database="slovakia";
     
     
     
    [COLOR="red"][SIZE="5"]$field4=$_POST['field4'];
    $field5=$_POST['field5'];
    $num=$_post['num'];[/SIZE][/COLOR]echo"$num";
    $link =mysql_connect(localhost,'gisPrj6','$56ffhgh');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    echo '';
    mysql_select_db($database) or die( "Unable to select database");
     
     
    $table = 'eventtable';
     
    echo"$num";
    if (empty($field5)) {
        /*echo 'FirstName is either 0, empty, or not set at all';*/
        $query = "SELECT * FROM $table where FamilyName='$field4'";/*Year,Date,FamilyName,FirstName,EventType,AgeSpouse*/
    }
    else
    {
      $query = "SELECT * FROM $table where FamilyName='$field4' and FirstName='$field5'";
    }
     
     
    if (!$sth = mysql_query($query)) {
       die("Ausführen der Abfrage <b>$query</b> nicht möglich: ".mysql_error()."\n");
    } 
    /*else {
       echo "Ausführen der Abfrage <b>$query</b> war erfolgreich.\n<br />\n";
    }*/
     
    echo "<table border='1' cellpadding='2' cellspacing='0' width='790px'><tr>";
     
    /*echo "Table: <b>$table</b><br />\n";*/
    for ($i = 0; $i < mysql_num_fields($sth); $i++) {
       $col = mysql_field_name($sth,$i);
     
       echo "<td width='13%'> <b>$col&nbsp;&nbsp;</b> </td>";
    }
    echo "</tr></table>";
     
    echo "<table id='Table2' border='1' cellpadding='2' cellspacing='1' width='790px' height='300px'>";
     
     
    while ($array = mysql_fetch_row($sth)) {
    echo "<tr onmouseover='ChangeColor(this, true);' 
                  onmouseout='ChangeColor(this, false);' 
                  onclick=''>";
       foreach ($array as $col) {
     
          echo "<td width='13%'>$col&nbsp;&nbsp;&nbsp;</td>";
       }
     
    echo "</tr>";
     
    }
    echo "</table>";
     
    $query2 = "SELECT ObjectID FROM $table where FamilyName='$field4' and FirstName='$field5'";
    $test=mysql_query($query2);
     
     
    while ($array2 = mysql_fetch_row($test)) {
     
    	foreach ($array2 as $objID) {
         echo " $array2[$num]";
     
    }
    echo "</tr>";
     
    }
     
    echo"$num";
    mysql_free_result($sth);
     
    ?>
    </div>
     
     
    <div id="gmap"  style="position:absolute; top: 208px; left: 915px; width: 810px; height:500px; border-style:solid;border-width:3px;border-color:#7496C2">
    </div>
    </body>
    </html>

  14. #14
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your do

    Code PHP:
    echo"$num";

    What value is being shown?

    If on the <form> tag you change the attribute method to GET then the value passed from the browser to the server will be shown on the URL. If this is correct then the problem is server side if it is wrong then the problem is browser side.

    Code HTML4Strict:
    <form action="thisBackUpphpProject6Formate.php" method="get">

  15. #15
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hallo, i tried GET method also, but PHP display the contents of any variable but not "num" as if it's empty and in url space no change at all

    Code JavaScript:
    <html>
    <head>
       <!-- Script Sources-->
        <link rel="stylesheet" type="text/css" href="styles.css" />
        <style type="text/css">
        <!--@import url("styles.css")-->
        </style>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=DioG219lPJG3WTn3zmQqebsjVg" type="text/javascript"></script>
        <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>
        <script type="text/javascript">
     
     
     
          var gmap = null;
          var findTask = null;
          var params = null;
          var mapExtension = null;
          var gOverlays = null;
          var gOverlays1 = null;
          var bounds = null;
          var posLatLng = null;
     
     
    	function initialize() {
            // GMap construction
            gmap = new GMap2(document.getElementById('gmap'));
    	gmap.setCenter(new GLatLng(48.539444, 18.566389), 13); //Velke Pole
            gmap.enableScrollWheelZoom();
    	gmap.setMapType(G_HYBRID_MAP);
    	gmap.addControl(new GLargeMapControl3D());
    	gmap.addControl(new GMapTypeControl());
    	gmap.enableScrollWheelZoom();
     
     
    	// Set the min and max scale for each layer
    	bounds = gmap.getBounds();
    	var minMapScale = 11;
    	var maxMapScale = 19;
     
    	// get array of map types
    	var mapTypes = gmap.getMapTypes();
    	//Create MapExtension utility class
    	mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);
     
     
           // Find Task
            findTask = new esri.arcgis.gmaps.FindTask("http://g-ags93.hs-karlsruhe.de/ArcGIS/rest/services/slovakei/0617final_WGS/MapServer");
     cell();
    	}
        //Function for find
    	function executeFind(searchText){
    	// Find Parameters
    		 params = new esri.arcgis.gmaps.FindParameters();
    		 params.layerIds = [1];
     
    		 var qYear = document.getElementById("qYear").value;
     
    		 	params.searchFields = ["ObjectID"];
     
    		// clear map overlays and event listeners using MapExtension removeFromMap
    		mapExtension.removeFromMap(gOverlays);
     
    		// set find parameters
    		params.contains = false;
    		params.searchText = searchText;;
     
    		// execute find task
    		findTask.execute(params, findCompleteCallback);
    	}
     
     
    	//Function for Find function results (zoom to and info window)  
    	function findCompleteCallback(response) {
            	var house = response.findResults[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResults]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
     
    		var houseGeometry = house.feature.geometry[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResult]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.Feature]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// Feature.geometry is an array of GPolygon objects because, Hawaii for example is an ArcGIS Polygon that has multiple rings --
    		// where each ring is represented as a GPolygon object in Google Maps API
     
    		var infoWindowOptions1 = {
    			contentTabs: [{label:"Building", content: "<b><p>House Number 1850:  </b>{HsNr1850}<br/> <b>Owner:  </b>{owner}<br/><b>Usage:  </b>{house_usag}<br/>"},
    			{label:"Other", content:"<br/><b>House Number 1925:  </b>{HsNr1925}"}
    			],
    			selectedTab:0
    		};
     
    		// center and zoom to the result
    		var polygonBounds = houseGeometry.getBounds();
    		// GPolygon.getBounds method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GPolygon]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var zoomLevel = gmap.getBoundsZoomLevel(polygonBounds);
    		// GMap2.getBoundsZoomLevel method
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GMap2]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var polygonCenter = polygonBounds.getCenter();
    		// GLatLngBounds.getCenter method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GLatLngBounds]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		gmap.setCenter(polygonCenter, zoomLevel);
     
    		// add the findresutls to google map without any style
    		gOverlays = mapExtension.addToMap(house, null, infoWindowOptions1);
          }
     
     
    	function ChangeColor(tableRow, highLight)
    	{
    		if (highLight)
    		{
    		tableRow.style.backgroundColor = '#7496C2';
    		}
    		else
    		{
    		tableRow.style.backgroundColor = 'white';
    		}
    	}
     
    var num;
     
    function setrownum(par)
    {
     document.getElementById('idnum').value = par;
     num=par;
     
    }
    function  getrownum()
    {
    return num;
    }
    	function cell(){
    		var tableElem = document.getElementById('Table2').getElementsByTagName('tr');
    		for (i = 0; i < tableElem.length; i++) {
    			tableElem[i].onclick = function() {
    				alert(this.rowIndex + 1);
    			par=this.rowIndex+1;
    			setrownum(par);
    		        alert(getrownum()*10);
     
    				}
     
    		}
     
    	alert(num*100);
      	}
     
      </script>
     
     
    </head>
     
     
    <body onload="initialize()">
     
    <div id ="logoCont" style="background-color: #7496C2;">
    	<div class = "headline">Cultural Heritage Map of Velk&eacute; Pole, Slovakia
     
    	</div>
    </div>
     
    <div id="topRightCont" class = "content" style="width: 415px;"><h1>Enter in Last and First Name</h1> 
    	<form action="thisBackUpphpProject6Formate.php" method="post">
     
    	Family Name:<input type="text" name="field4"><br>
    	First Name:<input type="text" name="field5"><br>
     
    	<input type="Submit">
     
    	<form action="thisBackUpphpProject6Formate.php" method="get">
    	 hidden: <input type="hidden" id="idnum" name="num" value=""><br>
    	</form>
     
    <div id = "credit" style="position:absolute;top: 817px;">
    	<table>
    	<tr>
    		<td style="vertical-align:top;">
    		<div class = "quicklinks" >
    		&copy; Hochschule Karlsruhe - Technik und Wirtschaft 2009, <a href="impressum.html">Impressum</a>
    		</div>
    		</td>
    		<td style="vertical-align:top;width:15px;">
    		</td>  
    		<td style= "width:225px;">
    		<a href="http://www.daad.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/daad.gif" width="179" height="13" border="0"></a>
    		<a href="http://www.asiin.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/asiin_klein.jpg" width="100" height="53" border="0" vertical-align="bottom" align="left"></a> 
    		<a href="http://www.facebook.com/pages/Fakult%C3%A4t-f%C3%BCr-Geomatik-Hochschule-Karlsruhe/166116110093298"><img src="http://www.g.hs-karlsruhe.de/geo/bilder_neue/facebook-logo.png" width="100" height="38" border="0" align = "right" vertical-align="bottom"></a>
    		</td>
    	</tr> 
    	</table>
          </div>	
     
    </form>
     
     
    </div>
     
     
    <div id="navcontainer" style="position: absolute; top: 185px; left: 15px; width: 815px; height:25px;">
    <ul id="navlist">
    <li id="active">
    	<li><a href="HomePage.html">Home</a></li>
    	<li><a href="Map.html">Map</a></li>
    	<li><a href="History.html">History</a></li>
    	<li><a href="About.html">About</a></li>
    </ul>
    </div>
     
     
     
    <div style="position:absolute; top: 208px; left: 15px; width: 810px; height:500px; overflow:auto; border-style:solid;border-width:3px;border-color:#7496C2">
    <?php
     
    $username="gisPrj6@localhost";/*g-ags93*/
    $password="$dfhg
    $database="slovakia";
     
     
     
    $field4=$_POST['field4'];
    $field5=$_POST['field5'];
    $num=$_GET['num'];
     
    echo"$num";
    $link =mysql_connect(localhost,'gisPrj6','$dfhg
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    echo '';
    mysql_select_db($database) or die( "Unable to select database");
     
     
    $table = 'eventtable';
     
    echo"$num";
    if (empty($field5)) {
        /*echo 'FirstName is either 0, empty, or not set at all';*/
        $query = "SELECT * FROM $table where FamilyName='$field4'";/*Year,Date,FamilyName,FirstName,EventType,AgeSpouse*/
    }
    else
    {
      $query = "SELECT * FROM $table where FamilyName='$field4' and FirstName='$field5'";
    }
     
     
    if (!$sth = mysql_query($query)) {
       die("Ausführen der Abfrage <b>$query</b> nicht möglich: ".mysql_error()."\n");
    } 
    /*else {
       echo "Ausführen der Abfrage <b>$query</b> war erfolgreich.\n<br />\n";
    }*/
     
    echo "<table border='1' cellpadding='2' cellspacing='0' width='790px'><tr>";
     
    /*echo "Table: <b>$table</b><br />\n";*/
    for ($i = 0; $i < mysql_num_fields($sth); $i++) {
       $col = mysql_field_name($sth,$i);
     
       echo "<td width='13%'> <b>$col&nbsp;&nbsp;</b> </td>";
    }
    echo "</tr></table>";
     
    echo "<table id='Table2' border='1' cellpadding='2' cellspacing='1' width='790px' height='300px'>";
     
     
    while ($array = mysql_fetch_row($sth)) {
    echo "<tr onmouseover='ChangeColor(this, true);' 
                  onmouseout='ChangeColor(this, false);' 
                  onclick=''>";
       foreach ($array as $col) {
     
          echo "<td width='13%'>$col&nbsp;&nbsp;&nbsp;</td>";
       }
     
    echo "</tr>";
     
    }
    echo "</table>";
     
    $query2 = "SELECT ObjectID FROM $table where FamilyName='$field4' and FirstName='$field5'";
    $test=mysql_query($query2);
     
     
    while ($array2 = mysql_fetch_row($test)) {
     
    	foreach ($array2 as $objID) {
         echo " $array2[$num]";
     
    }
    echo "</tr>";
     
    }
     
    echo"$num";
    mysql_free_result($sth);
     
    ?>
    </div>
     
     
    <div id="gmap"  style="position:absolute; top: 208px; left: 915px; width: 810px; height:500px; border-style:solid;border-width:3px;border-color:#7496C2">
    </div>
    </body>
    </html>

  16. #16
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have

    Code HTML4Strict:
        <form action="thisBackUpphpProject6Formate.php" method="post">
     
        Family Name:<input type="text" name="field4"><br>
        First Name:<input type="text" name="field5"><br>
     
        <input type="Submit">
     
        <form action="thisBackUpphpProject6Formate.php" method="get">
         hidden: <input type="hidden" id="idnum" name="num" value=""><br>
        </form>

    The second <form> tag will terminate the first form and start a new one. num should only appear in the URL if the second form was submitted. The first form is a "post" so no parameters will appear.

    Remove the second <form> tag.and for the moment change the type to "text". Thus


    Code HTML4Strict:
        <form action="thisBackUpphpProject6Formate.php" method="get">
     
        Family Name:<input type="text" name="field4"><br>
        First Name:<input type="text" name="field5"><br>
     
        <input type="Submit">
     
         NUM: <input type="text" id="idnum" name="num" value=""><br>
        </form>

    As you select a row the NUM: should be updated.

    When you submit the form "num" should be transferred.

    Also notice you have

    Code PHP:
    echo "<tr onmouseover='ChangeColor(this, true);' 
                  onmouseout='ChangeColor(this, false);' 
                  onclick=''>";

    Remove the onclick entirely.

  17. #17
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    <html>
    <head>
       <!-- Script Sources-->
        <link rel="stylesheet" type="text/css" href="styles.css" />
        <style type="text/css">
        <!--@import url("styles.css")-->
        </style>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=DioG219lPJG3WTn3zmQqebsjVg" type="text/javascript"></script>
        <script src="http://serverapi.arcgisonline.com/jsapi/gmaps/?v=1.6" type="text/javascript" ></script>
        <script type="text/javascript">
     
     
     
          var gmap = null;
          var findTask = null;
          var params = null;
          var mapExtension = null;
          var gOverlays = null;
          var gOverlays1 = null;
          var bounds = null;
          var posLatLng = null;
     
     
    	function initialize() {
            // GMap construction
            gmap = new GMap2(document.getElementById('gmap'));
    	gmap.setCenter(new GLatLng(48.539444, 18.566389), 13); //Velke Pole
            gmap.enableScrollWheelZoom();
    	gmap.setMapType(G_HYBRID_MAP);
    	gmap.addControl(new GLargeMapControl3D());
    	gmap.addControl(new GMapTypeControl());
    	gmap.enableScrollWheelZoom();
     
     
    	// Set the min and max scale for each layer
    	bounds = gmap.getBounds();
    	var minMapScale = 11;
    	var maxMapScale = 19;
     
    	// get array of map types
    	var mapTypes = gmap.getMapTypes();
    	//Create MapExtension utility class
    	mapExtension = new esri.arcgis.gmaps.MapExtension(gmap);
     
     
           // Find Task
            findTask = new esri.arcgis.gmaps.FindTask("http://g-ags93.hs-karlsruhe.de/ArcGIS/rest/services/slovakei/0617final_WGS/MapServer");
     
    	}
        //Function for find
    	function executeFind(searchText){
    	// Find Parameters
    		 params = new esri.arcgis.gmaps.FindParameters();
    		 params.layerIds = [1];
     
    		 var qYear = document.getElementById("qYear").value;
     
    		 	params.searchFields = ["ObjectID"];
     
    		// clear map overlays and event listeners using MapExtension removeFromMap
    		mapExtension.removeFromMap(gOverlays);
     
    		// set find parameters
    		params.contains = false;
    		params.searchText = searchText;;
     
    		// execute find task
    	findTask.execute(params, findCompleteCallback);
     
    	}
     
     
    	//Function for Find function results (zoom to and info window)  
    	function findCompleteCallback(response) {
            	var house = response.findResults[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResults]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
     
    		var houseGeometry = house.feature.geometry[0];
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.FindResult]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// [url=http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/gmaps/help/topics/apiref.htm#class_esri.arcgis.gmaps.Feature]API Reference: ArcGIS JavaScript Extension for Google Maps[/url]
    		// Feature.geometry is an array of GPolygon objects because, Hawaii for example is an ArcGIS Polygon that has multiple rings --
    		// where each ring is represented as a GPolygon object in Google Maps API
     
    		var infoWindowOptions1 = {
    			contentTabs: [{label:"Building", content: "<b><p>House Number 1850:  </b>{HsNr1850}<br/> <b>Owner:  </b>{owner}<br/><b>Usage:  </b>{house_usag}<br/>"},
    			{label:"Other", content:"<br/><b>House Number 1925:  </b>{HsNr1925}"}
    			],
    			selectedTab:0
    		};
     
    		// center and zoom to the result
    		var polygonBounds = houseGeometry.getBounds();
    		// GPolygon.getBounds method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GPolygon]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var zoomLevel = gmap.getBoundsZoomLevel(polygonBounds);
    		// GMap2.getBoundsZoomLevel method
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GMap2]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		var polygonCenter = polygonBounds.getCenter();
    		// GLatLngBounds.getCenter method 
    		// [url=http://code.google.com/apis/maps/documentation/reference.html#GLatLngBounds]Google Maps JavaScript API V2 Reference - Google Maps JavaScript API V2 - Google Code[/url]
     
    		gmap.setCenter(polygonCenter, zoomLevel);
     
    		// add the findresutls to google map without any style
    		gOverlays = mapExtension.addToMap(house, null, infoWindowOptions1);
          }
     
     
    	function ChangeColor(tableRow, highLight)
    	{
    		if (highLight)
    		{
    		tableRow.style.backgroundColor = '#7496C2';
    		}
    		else
    		{
    		tableRow.style.backgroundColor = 'white';
    		}
    	}
     
    var num;
     
    function setrownum(par)
    {
     document.getElementById('idnum').value = par;
     num=par;
     
    }
    function  getrownum()
    {
    return num;
    }
    	function cell(){
    		var tableElem = document.getElementById('Table2').getElementsByTagName('tr');
    		for (i = 0; i < tableElem.length; i++) {
    			tableElem[i].onclick = function() {
    				alert(this.rowIndex + 1);
    			par=this.rowIndex+1;
    			setrownum(par);
    		        alert(getrownum()*10);
     
    				}
     
    		}
     
    	alert(num*100);
      	}
     
      </script>
     
     
    </head>
     
     
    <body onload="initialize()">
     
    <div id ="logoCont" style="background-color: #7496C2;">
    	<div class = "headline">Cultural Heritage Map of Velk&eacute; Pole, Slovakia
     
    	</div>
    </div>
     
    <div id="topRightCont" class = "content" style="width: 415px;"><h1>Enter in Last and First Name</h1> 
    	<form action="thisBackUpphpProject6Formate.php" method="get">
     
        Family Name:<input type="text" name="field4"><br>
        First Name:<input type="text" name="field5"><br>
     
        <input type="Submit">
     
         NUM: <input type="text" id="idnum" name="num" value=""><br>
     
     
    <div id = "credit" style="position:absolute;top: 817px;">
    	<table>
    	<tr>
    		<td style="vertical-align:top;">
    		<div class = "quicklinks" >
    		&copy; Hochschule Karlsruhe - Technik und Wirtschaft 2009, <a href="impressum.html">Impressum</a>
    		</div>
    		</td>
    		<td style="vertical-align:top;width:15px;">
    		</td>  
    		<td style= "width:225px;">
    		<a href="http://www.daad.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/daad.gif" width="179" height="13" border="0"></a>
    		<a href="http://www.asiin.de"><img src="http://www.g.hs-karlsruhe.de/geo/img/asiin_klein.jpg" width="100" height="53" border="0" vertical-align="bottom" align="left"></a> 
    		<a href="http://www.facebook.com/pages/Fakult%C3%A4t-f%C3%BCr-Geomatik-Hochschule-Karlsruhe/166116110093298"><img src="http://www.g.hs-karlsruhe.de/geo/bilder_neue/facebook-logo.png" width="100" height="38" border="0" align = "right" vertical-align="bottom"></a>
    		</td>
    	</tr> 
    	</table>
          </div>	
     
    </form>
     
     
    </div>
     
     
    <div id="navcontainer" style="position: absolute; top: 185px; left: 15px; width: 815px; height:25px;">
    <ul id="navlist">
    <li id="active">
    	<li><a href="HomePage.html">Home</a></li>
    	<li><a href="Map.html">Map</a></li>
    	<li><a href="History.html">History</a></li>
    	<li><a href="About.html">About</a></li>
    </ul>
    </div>
     
     
     
    <div style="position:absolute; top: 208px; left: 15px; width: 810px; height:500px; overflow:auto; border-style:solid;border-width:3px;border-color:#7496C2">
    <?php
     
    $username="gisPrj6@localhost";/*g-ags93*/
    $password="$l0mn,";
    $database="slovakia";
     
     
     
    $field4=$_GET['field4'];
    $field5=$_GET['field5'];
    $num=$_GET['num'];
     
    echo "$num";/*NOTHING IS DISPLAYED */
     
    $link =mysql_connect(localhost,'gisPrj6','$lmn,4');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
     
    mysql_select_db($database) or die( "Unable to select database");
     
     
    $table = 'eventtable';
     
     
    if (empty($field5)) {
        /*echo 'FirstName is either 0, empty, or not set at all';*/
        $query = "SELECT * FROM $table where FamilyName='$field4'";/*Year,Date,FamilyName,FirstName,EventType,AgeSpouse*/
    }
    else
    {
      $query = "SELECT * FROM $table where FamilyName='$field4' and FirstName='$field5'";
    }
     
     
    if (!$sth = mysql_query($query)) {
       die("Ausführen der Abfrage <b>$query</b> nicht möglich: ".mysql_error()."\n");
    } 
    /*else {
       echo "Ausführen der Abfrage <b>$query</b> war erfolgreich.\n<br />\n";
    }*/
     
    echo "<table border='1' cellpadding='2' cellspacing='0' width='790px'><tr>";
     
    /*echo "Table: <b>$table</b><br />\n";*/
    for ($i = 0; $i < mysql_num_fields($sth); $i++) {
       $col = mysql_field_name($sth,$i);
     
       echo "<td width='13%'> <b>$col&nbsp;&nbsp;</b> </td>";
    }
    echo "</tr></table>";
     
    echo "<table id='Table2' border='1' cellpadding='2' cellspacing='1' width='790px' height='300px'>";
     
     
    while ($array = mysql_fetch_row($sth)) {
    echo "<tr onmouseover='ChangeColor(this, true);' 
                  onmouseout='ChangeColor(this, false);' 
                  onclick='cell();'>";
       foreach ($array as $col) {
     
          echo "<td width='13%'>$col&nbsp;&nbsp;&nbsp;</td>";
       }
     
    echo "</tr>";
     
    }
    echo "</table>";
     
    $query2 = "SELECT ObjectID FROM $table where FamilyName='$field4' and FirstName='$field5'";
    $test=mysql_query($query2);
     
     
    while ($array2 = mysql_fetch_row($test)) {
     
    	foreach ($array2 as $objID) {
         /*print_r(array_values($array2(0)));*//*echo " $array2[$num]";*/
         echo " $array2[$num]";/*NOTHING IS DISPLAYED */
    }
    echo "</tr>";
     
    }
     
    echo"   $num";/*NOTHING IS DISPLAYED */
    mysql_free_result($sth);
     
    ?>
    </div>
     
     
    <div id="gmap"  style="position:absolute; top: 208px; left: 915px; width: 810px; height:500px; border-style:solid;border-width:3px;border-color:#7496C2">
    </div>
    </body>
    </html>

  18. #18
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,
    please tell me why the variable $num does not display any value when i try to display its contents..and how to display it.........

  19. #19
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Elpharaoh View Post
    hi,
    please tell me why the variable $num does not display any value when i try to display its contents..
    It's because all of the PHP runs first, before the web page is sent to the client. Once there, the javascript then runs.

    Quote Originally Posted by Elpharaoh View Post
    and how to display it.........
    By restructuring your code so that you can use Ajax to pass data to a php page and receive a response from it.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  20. #20
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is't there any other way to reference an array by the value of that variable $num....
    note: the array is my_sql query......

  21. #21
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Elpharaoh View Post
    is't there any other way to reference an array by the value of that variable $num....
    Not all in one go. No.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  22. #22
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    since it's not possible to make it in one go...can you tell me how to make it in several goes...

  23. #23
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Elpharaoh View Post
    since it's not possible to make it in one go...can you tell me how to make it in several goes...
    The techniques to use depend on what you want to achieve.

    What are you wanting to use num for?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  24. #24
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i have certain query as below:

    $query2 = "SELECT ObjectID FROM $table where FamilyName='$field4' and FirstName='$field5'";
    $test=mysql_query($query2);
    while ($array2 = mysql_fetch_row($test))
    {
    foreach ($array2 as $objID)
    {
    /*print_r(array_values($array2(0)));*//*echo " $array2[$num]";*/
    /*echo " $array2["."<script type='text/javascript'> num; </script>"; . "]";*/
    /*NOTHING IS DISPLAYED */
    }
    echo "</tr>";
    }

    the array "$array2" contains rows belongs to one attribute "ObjectID"..and i want to refere to this array elements depending on the value of the variable "num"..in other words, i want to use num as index, like:

    echo " $array2[$num]";

  25. #25
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Elpharaoh View Post
    actually i have certain query as below:
    It seems that the value of num and the contents of the table are quite circuitous.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •