I captured the values using the following javascript code in my html form:
<script type="text/javascript">
<!--
function querySt(ji) {
dwnstr = window.location.search.substring(1);
dwnstr = dwnstr.toLowerCase();
gy = dwnstr.split("&");
for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
return "";
}
cust_lat = querySt("lt");
cust_long = querySt("lg");
document.write(cust_lat);
document.write(cust_long);
-->
</script>
As you can see I wrote the captured variables to my screen, so I know that the code works.
I need the value of the variables cust_lat
& cust_long
put into two hidden fields on my form (form1
) replacing the default values of 0
type=hidden name=cust_lat><input style="WIDTH: 79px; HEIGHT: 22px" value="0"
type=hidden name=cust_long><input style="WIDTH: 81px; HEIGHT: 22px" value="0"
the result is then passed to index.php
using the following line:
开发者_Go百科<form method="get" name="form1" action="index.php">
Right now the fields are coming through to mysql as the defaults: 0
0
I just need to replace these default values with the captured values.
I hope someone can help
Thank you,
Ray Ward$_GET['fieldname'] is the equivalent in php as request.querystring("variable_name") is in asp
give your hidden inputs an id and use
document.getElementById('hiddenbox').value="The Value Here"
You need to use DOM javascript to set the values. First, specify an id for each of your elements:
<input type='hidden' name='cust_lat' id='cust_lat'>
<input type='hidden' name='cust_long' id='cust_long'>
Then, use document.getElementById('cust_lat').value = whatever;
in your page load javascript.
<type=hidden name=cust_long value=$_GET['fieldname']>
PHP method:
<?php
$lt = (isset($_GET['lt']) && is_numeric($_GET['lt'])) ? (float)$_GET['lt'] : 0;
$lg = (isset($_GET['lg']) && is_numeric($_GET['lg'])) ? (float)$_GET['lg'] : 0;
echo <<< HTML
<input type="hidden" name="cust_lat" value="{$lt}">
<input type="hidden" name="cust_long" value="{$lg}">
HTML;
?>
精彩评论