Hello and thanks for the help in advance. I'm new to JavaScript and ajax. I'm trying to get a php code to display in the same page based on a variable that has been predefined elsewhere in the page. I found the code below using an object to display the php in the same page. my problem is when i try to add the variable it doesn't get passed with the php request. Any help or ideas would be appreciated.
<form id="locform" name="locform" method="get">
<input type="text" name="box1" id="box1">
</form>
<script type="text/javascript">
var y = localStorage.getItem("location");
document.locform.box1.value = y;
document.getElementById("example").innerHTML = '<object type="text/html" data="loc.php?loc=" + y></object>';
</script>
<div id="example"></div>
y
as string not as a variable!<object />
to do an AJAX call is very creative but not your best bet. I would recommend you to look into AJAX calls. W3Schools has a great tutorial.data="loc.php?loc='+y+'"