在提交之前将文本框值附加到href链接 [英] append textbox value to href link before submit

查看:74
本文介绍了在提交之前将文本框值附加到href链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个带有表格和文本框的页面。

之前提交表格我想要chek如果插入的值在

文本框已存在于数据库中。

所以我需要通过javascript链接将文本框值传递到另一个

页面进行检查。

我的代码是

< a href =" javascript :location.href =''page_check.php''" Go check < / a>

和这个工作并打开page_check.php

但是当我想附加文本框值时,代码不起作用。我知道

我犯了错误


< a href =" javascript :location.href =''page_check.php ?Box =''+

document.formName.textboxName.value" Go check< / a>


有什么建议吗?

问候

Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href=''page_check.php'' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href=''page_check.php?Box ='' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards

推荐答案

pt36写道:
pt36 wrote:




我有一个带有表格和文本框的页面。

之前提交表格我想要chek如果插入值在

文本框中已存在于数据库中。

所以我需要通过javascript链接将文本框值传递到另一个

页面进行检查。

my代码是

< a href =" javascript :location.href =''page_check.php''" Go check< / a>

和这个工作并打开page_check.php

但是当我想附加文本框值时,代码不起作用。我知道

我犯了错误


< a href =" javascript :location.href =''page_check.php ?Box =''+

document.formName.textboxName.value" Go check< / a>


有什么建议吗?

问候
Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href=''page_check.php'' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href=''page_check.php?Box ='' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards



由于检查数据库是在服务器上完成的,在我看来,你想要的是AJAX。有一个onclick = foo()。在foo中,您可以使用AJAX调用

并根据是否b / b
没有匹配或匹配来向浏览器返回消息。如果这是在

提交页面之前进行检查,那么去掉检查按钮,保持动作

作为你想要提交页面的位置,放一个& ; return foo()"在

表单定义中,从foo返回false或true。


你的意思是什么不起作用? php文件没有看到

值吗? php文件是否看到了值,但是你没有获得当前页面的价值

?会发生什么?

Since checking of a database is done on the server, it seems to me that
what you want is AJAX. Have an "onclick=foo()". In foo you would make
the AJAX call and return a message to the browser depending upon whether
there is no match or is a match. If this is for checking before
submitting the page, then get rid of the check button, keep the action
as the where you want the page submitted to, put a "return foo()" in the
form definition, and return either false or true from foo.

What do you mean by it doesn''t work? Does the php file not see the
value? Does the php file see the value, but you don''t get values back
to the current page? What happens?


7月7日9:03 pm,pt36< key.albe ... @ gmail.comwrote:
On Jul 7, 9:03 pm, pt36 <key.albe...@gmail.comwrote:




我有一个带有表格和文本框的页面。

之前提交我想要的表格如果

文本框中的插入值已存在于数据库中。

所以我需要通过javascript链接将文本框值传递给另一个

要检查的页面。

我的代码是

< a href =" javascript :location.href =''page_check.php'' 去检查< / a>

和这项工作并打开page_check.php

但是当我想追加文本框值时,代码不是工作。我知道

我犯了错误


< a href =" javascript :location.href =''page_check.php ?Box =''+

document.formName.textboxName.value" Go check< / a>


有什么建议吗?

问候
Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href=''page_check.php'' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href=''page_check.php?Box ='' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards



这个:


< html>

< head>

< script>

函数changeURL(){

var lnk = document.getElementById(''somelink'');

lnk.href = lnk.href +"?" + document.getElementById(''txtbx'')。value;

}

< / script>

< / head>

< body>

< input type =" text"值= QUOT;" ID = QUOT; txtbx" />

< a href =" some_file.html" id =" somelink">< input type =" button"

value =" check it" onmousedown事件= QUOT; changeURL();" />< / a>

< / body>

< / html>


或者,我认为这个更好:


< html>

< head>

< script>

函数changeURL(){

window.location =" some_file.php" +? +

document.getElementById(''txtbx'')。value;

}

< / script>

< / head>

< body>

< input type =" text"值= QUOT;" ID = QUOT; txtbx" />

< input type =" button" value ="检查 onmousedown事件= QUOT; changeURL();" />

< / body>

< / html>

this:

<html>
<head>
<script>
function changeURL(){
var lnk = document.getElementById(''somelink'');
lnk.href = lnk.href + "?" + document.getElementById(''txtbx'').value;
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<a href="some_file.html" id="somelink"><input type="button"
value="Check it" onmousedown="changeURL();" /></a>
</body>
</html>

Or, I think this one is better:

<html>
<head>
<script>
function changeURL(){
window.location = "some_file.php" + "?" +
document.getElementById(''txtbx'').value;
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<input type="button" value="Check it" onmousedown="changeURL();" />
</body>
</html>


7月7日,9日: 03 pm,pt36< key.albe ... @ gmail.comwrote:
On Jul 7, 9:03 pm, pt36 <key.albe...@gmail.comwrote:




我有一个页面如果在数据库中已经存在

文本框中的插入值,那么在提交我想要的表格之前,需要提供一个表格和一个文本框。



所以我需要通过javascript链接将文本框值传递到另一个

页面进行检查。

我的代码是

< ; a href =" javascript :location.href =''page_check.php''" Go check< / a>

和此工作并打开page_check。 php


但是当我想附加文本框值时,代码不起作用。我知道

我犯了错误


< a href =" javascript :location.href =''page_check.php ?Box =''+

document.formName.textboxName.value" Go check< / a>


有什么建议吗?

问候
Hi

I have a page with a form and a textbox.
before to submit the form I want to chek if the inserted value in the
textbox is already present in a database.
So I need to pass the textbox value by a javascript link to another
page to check.
my code is
<a href="javascript:location.href=''page_check.php'' "Go check </a>
and this work and open page_check.php

but when I want to append the textbox value, the code not work. I know
I make mistake

<a href="javascript:location.href=''page_check.php?Box ='' +
document.formName.textboxName.value "Go check </a>

Any suggest ?
Regards



你可以试试这个:


< html>

< ; head>

< script>

函数changeURL(){

var lnk = document.getElementById(''somelink'');

lnk.href = lnk.href +"?" + document.getElementById(''txtbx'')。value

}

< / script>

< / head>

< body>

< input type =" text"值= QUOT;" ID = QUOT; txtbx" />

< a href =" some_file.php" id =" somelink">< input type =" button"

value =" check it" onmousedown事件= QUOT; changeURL();" />< / a>

< / body>

< / html>


或者,我认为这是更好的:


< html>

< head>

< script>

function changeURL(){

window.location =" some_file.php" +? +

document.getElementById(''txtbx'')。value;

}

< / script>

< / head>

< body>

< input type =" text"值= QUOT;" ID = QUOT; txtbx" />

< input type =" button" value ="检查 onmousedown事件= QUOT; changeURL();" />

< / body>

< / html>

you can try this:

<html>
<head>
<script>
function changeURL(){
var lnk = document.getElementById(''somelink'');
lnk.href = lnk.href + "?" + document.getElementById(''txtbx'').value
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<a href="some_file.php" id="somelink"><input type="button"
value="Check it" onmousedown="changeURL();" /></a>
</body>
</html>

or, I think this is better:

<html>
<head>
<script>
function changeURL(){
window.location = "some_file.php" + "?" +
document.getElementById(''txtbx'').value;
}
</script>
</head>
<body>
<input type="text" value="" id="txtbx" />
<input type="button" value="Check it" onmousedown="changeURL();" />
</body>
</html>


这篇关于在提交之前将文本框值附加到href链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆