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:
dim mode : mode = lcase(request("foo"))
But the value is empty when I perform the same action in Chrome.
Could anyone help?
You need to quote your attributes:
Also "submit" is a reserved word in JavaScript. If you have a function called "submit" it may not work.
List of reserved words: http://www.javascripter.net/faq/reserved.htm
You have a quote missing. It should look like this:
In addition, submit() is a method on a form, so you must make sure your button is within
<form></form>
tags.From the W3C specification:
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.Change the HTML to this and it should work for all browsers:
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.
If you will it makes easier for google or other to find your form. Give the button an title and alt:
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:
The type attribute for
button
can be submit, button, or reset and unless this is explicitly specified, will vary from browser to browser.