Jump to content

Recommended Posts

I have currently got a while loop retrieving the relevant data from a database and drawing polygons.On the polygon onClick()action a buildingClick function is called passing a few variables.in that buildingClick function i am trying to pass these variables to a new page to display in a text area but i cant get it to work.the new page opens but doesnt display the variables as intended.

////////////////////////////////////////////////////////////////////////////////////////////////

EXTMAP.PHP

<?php  

            while($info = mysql_fetch_array( $data )){

$id = $info['id'];

$name = $info['name'];

$b_desc = $info['information'];

                echo "<polygon fill=".$info['fill_colour']." stroke=\"black\" onclick=\"buildingClick($id,'$name','$b_desc')\"  points=".$info['coordinates']."/>";

        }

?>

/////////////////////////////////////////

<script type="text/javascript">   

var mywin;

var isOpen = false;

var searchInt;

var passVal;

// This function is called when a building is clicked.   

function buildingClick(id,name,desc)

{

passVal = desc;

mywin = window.location.href = "informationPage.html";

searchInt = setInterval(function(){if(isOpen){mywin.document.getElementById("infoArea").value = passVal; clearInterval(searchInt);}}, 100);

}  

    </script>

//////////////////////////////////////////////////////////////////////////////////

INFORMATIONPAGE.HTML

 

<script type="text/javascript">

window.onload = function(){window.opener.window["isOpen"] = true;};

</script>

 

<div class="infoDiv" id=infoDiv>

  Name: <input type="text" disabled="true" id="bName" />

</div>

/////////////////////////////////////////////////////////////////////////////////////

 

If anybody knows why this isnt working or ow i could make it work it would be much appreciated.

Eoin.

1) Are your php variable values outputting in your js onclick? (view source of rendered page to verify)

 

2) Are the js variables being passed to your buildingClick() function? (use alert() or console.log()  to verify)

 

3) mywin = window.location.href = "informationPage.html"; might possibly be problematic...you are setting the current window's location to a new location too.. stands to reason you are being redirected to informationPage.html before the rest of your js has a chance to execute

 

4) mywin.document.getElementById("infoArea") I see in your informationpage.html the div id is "infoDiv" not "infoArea"

 

 

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.