1

我在我的 html 表单中使用以下 javascript 代码捕获了这些值:

<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>

如您所见,我将捕获的变量写入屏幕,因此我知道代码有效。

我需要变量的值cust_latcust_long放入表单(form1)上的两个隐藏字段中,替换默认值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" 

index.php然后使用以下行将结果传递给:

<form method="get" name="form1" action="index.php">

现在,这些字段作为默认值传入 mysql:0 0

我只需要用捕获的值替换这些默认值。

我希望有人能帮帮忙

谢谢你,
雷·沃德

4

5 回答 5

0

$_GET['fieldname'] 在 php 中等同于 request.querystring("variable_name") 在 asp 中

于 2011-05-18T18:16:00.387 回答
0
<type=hidden name=cust_long value=$_GET['fieldname']>
于 2011-05-18T18:20:06.997 回答
0

给你的隐藏输入一个 id 并使用 document.getElementById('hiddenbox').value="The Value Here"

于 2011-05-18T18:17:01.430 回答
0

PHP方法:

<?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;
?>
于 2011-05-18T18:24:53.873 回答
0

您需要使用 DOM javascript 来设置值。首先,为每个元素指定一个 id:

<input type='hidden' name='cust_lat' id='cust_lat'> <input type='hidden' name='cust_long' id='cust_long'>

然后,document.getElementById('cust_lat').value = whatever;在您的页面中使用加载 javascript。

于 2011-05-18T18:18:20.087 回答