1

我有一个包含两个字段名称和姓氏的表格。写下这些字段,然后我点击提交而不采取任何行动。在我的网站之前http://www.xn--nonlos-8wa.html 表格是

    <form method="GET">
        <input type=”text” nome=”id” value=”qui il tuo testo”&gt;
<input type=”text” cognome=”id” value=”qui il tuo testo”&gt;
        <input type= "submit" name= "submit" value= "Invia" >
        </form>

提交后的站点是:

http://www.xn--nonlos-8wa.html/?name=pollo&cognome=che+sono&nome=a&cognome=b&nome=c&cognome=d

这是我发送了三个表单的站点,但现在我想更改我发送的第二个表单的名称。除非程序的数据与我读取的站点和受变量有关。我编辑了字段(变量),但因为我要在网站上重写。从 name=a 和 surname=b 表示该站点将成为新参数。

http://www.xn--nonlos-8wa.html/?nome=pollo&cognome=che+sono&nome=565655&cognome=8765634&nome=c&cognome=d.

然后不使用表单的提交......如何???如何通过仅更改感兴趣的值来编辑站点?

在我提交的网站之前是

http://www.xn--nonlos-8wa.html/?name=pollo&cognome=che+sono&nome=a&cognome=b&nome=c&cognome=d

使用脚本 Javascrits 后(可能吗??)是 http://www.xn--nonlos-8wa.html/?nome=pollo&cognome=che+sono&nome=565655&cognome=8765634&nome=c&cognome=d

4

2 回答 2

1

您的问题可能存在翻译问题,但我想您是在问如何设置从表单传递的参数的名称?

最简单的方法就是更改输入的名称:

<input type=”text” name=”surname” value=”qui il tuo testo”&gt;

但是,如果由于某种原因无法编辑 html,您也可以使用 jQuery 发送请求并在 json 对象中设置参数:

$.ajax({
    type: "GET",
    url: "http://www.xn--nonlos-8wa.html/",
    data: {name: "a", surname:"b"}
});
于 2012-07-22T22:11:58.980 回答
0

您必须明确定义表单提交到的 URL,否则表单操作将变为 URL 中的任何内容,并将复制您的查询字符串变量。

<form method="GET" action="testo.html">
    ...
</form>

然后它将转到 testo.html?nome=pollo&cognome=che+sono。

当然,您可以将“testo.html”更改为您的测试实际所在的任何页面。

于 2012-07-22T22:24:42.283 回答