按钮在Chrome中不起作用

时间:2022-08-23 11:45:30

I have

<button name="foo" value="bar" onclick="submit()" >foobar</button>

When I click the button in firefox, the value is transferred (is foo) and I can read the value like the following:

当我单击firefox中的按钮时,值被传输(是foo),我可以读取如下值:

dim mode                : mode                = lcase(request("foo"))  

But the value is empty when I perform the same action in Chrome.

但是当我在Chrome中执行相同的操作时,该值为空。

Could anyone help?

有人可以帮忙吗?

5 个解决方案

#1


4  

Different browsers have different default submit behaviors for buttons. If you want a button to submit the form (and thus post its name and value pair), you'll have to use:

不同的浏览器对按钮有不同的默认提交行为。如果您想要一个按钮来提交表单(并因此发布其名称和值对),您将不得不使用:

<button type="submit" name="foo" value="bar" >foobar</button>

The type attribute for button can be submit, button, or reset and unless this is explicitly specified, will vary from browser to browser.

按钮的type属性可以是提交,按钮或重置,除非明确指定,否则因浏览器而异。

#2


1  

You have a quote missing. It should look like this:

你的报价遗失了。它应该如下所示:

<button name="foo" value="bar" onclick="submit()" >foobar</button>

In addition, submit() is a method on a form, so you must make sure your button is within <form></form> tags.

另外,submit()是表单上的方法,因此您必须确保您的按钮位于

标记内。

From the W3C specification:

从W3C规范:

Important: If you use the element in an HTML form, different browsers may submit different values. Internet Explorer, prior version 9, will submit the text between the <button> and </button> tags, while other browsers will submit the content of the value attribute. Use the <input> element to create buttons in an HTML form.

重要提示:如果您在HTML表单中使用该元素,则不同的浏览器可能会提交不同的值。 Internet Explorer(早期版本9)将在

#3


0  

You need to quote your attributes:

你需要引用你的属性:

<button name="foo" value="bar" onclick="submit()" >foobar</button>

Also "submit" is a reserved word in JavaScript. If you have a function called "submit" it may not work.

“submit”也是JavaScript中的保留字。如果你有一个名为“提交”的功能,它可能无法正常工作。

List of reserved words: http://www.javascripter.net/faq/reserved.htm

保留字列表:http://www.javascripter.net/faq/reserved.htm

#4


0  

If you will it makes easier for google or other to find your form. Give the button an title and alt:

如果您愿意,谷歌或其他人可以更轻松地找到您的表单。给按钮一个标题和alt:

 <button name="foo" title="submit" alt="submit for contact" valeu="" onclick="submit()" >foobar</button>

#5


0  

From what I remember, old versions of IE (maybe even 8) treat only the good old <input type="submit" /> as "real" submit button that is part of the form thus sending its value. So <button> in such browsers won't send its value.

根据我的记忆,IE的旧版本(甚至可能是8)仅将好的旧视为“真实”提交按钮,该按钮是表单的一部分,从而发送其值。所以这种浏览器中的

Change the HTML to this and it should work for all browsers:

将HTML更改为此,它应适用于所有浏览器:

<input type="submit" name="foo" value="foobar" onclick="this.value = 'bar';" />

As the value sent is the value seen, I had to use JavaScript trick to change the value upon click - as far as I know, can't do that without using client side script.

由于发送的值是看到的值,我不得不使用JavaScript技巧在点击时更改值 - 据我所知,如果不使用客户端脚本则不能这样做。

#1


4  

Different browsers have different default submit behaviors for buttons. If you want a button to submit the form (and thus post its name and value pair), you'll have to use:

不同的浏览器对按钮有不同的默认提交行为。如果您想要一个按钮来提交表单(并因此发布其名称和值对),您将不得不使用:

<button type="submit" name="foo" value="bar" >foobar</button>

The type attribute for button can be submit, button, or reset and unless this is explicitly specified, will vary from browser to browser.

按钮的type属性可以是提交,按钮或重置,除非明确指定,否则因浏览器而异。

#2


1  

You have a quote missing. It should look like this:

你的报价遗失了。它应该如下所示:

<button name="foo" value="bar" onclick="submit()" >foobar</button>

In addition, submit() is a method on a form, so you must make sure your button is within <form></form> tags.

另外,submit()是表单上的方法,因此您必须确保您的按钮位于

标记内。

From the W3C specification:

从W3C规范:

Important: If you use the element in an HTML form, different browsers may submit different values. Internet Explorer, prior version 9, will submit the text between the <button> and </button> tags, while other browsers will submit the content of the value attribute. Use the <input> element to create buttons in an HTML form.

重要提示:如果您在HTML表单中使用该元素,则不同的浏览器可能会提交不同的值。 Internet Explorer(早期版本9)将在

#3


0  

You need to quote your attributes:

你需要引用你的属性:

<button name="foo" value="bar" onclick="submit()" >foobar</button>

Also "submit" is a reserved word in JavaScript. If you have a function called "submit" it may not work.

“submit”也是JavaScript中的保留字。如果你有一个名为“提交”的功能,它可能无法正常工作。

List of reserved words: http://www.javascripter.net/faq/reserved.htm

保留字列表:http://www.javascripter.net/faq/reserved.htm

#4


0  

If you will it makes easier for google or other to find your form. Give the button an title and alt:

如果您愿意,谷歌或其他人可以更轻松地找到您的表单。给按钮一个标题和alt:

 <button name="foo" title="submit" alt="submit for contact" valeu="" onclick="submit()" >foobar</button>

#5


0  

From what I remember, old versions of IE (maybe even 8) treat only the good old <input type="submit" /> as "real" submit button that is part of the form thus sending its value. So <button> in such browsers won't send its value.

根据我的记忆,IE的旧版本(甚至可能是8)仅将好的旧视为“真实”提交按钮,该按钮是表单的一部分,从而发送其值。所以这种浏览器中的

Change the HTML to this and it should work for all browsers:

将HTML更改为此,它应适用于所有浏览器:

<input type="submit" name="foo" value="foobar" onclick="this.value = 'bar';" />

As the value sent is the value seen, I had to use JavaScript trick to change the value upon click - as far as I know, can't do that without using client side script.

由于发送的值是看到的值,我不得不使用JavaScript技巧在点击时更改值 - 据我所知,如果不使用客户端脚本则不能这样做。