Reputation: 10139
Alright, stupid simple question. I'm not very savvy with HTML. I have the following HTML:
<input type='submit' name='submitActivate' value='Activate'></input>
"Activate" is the text on the submit button. When I post the form, I can grab the input's value data on the destination page (which would be the string "Activate"). Is there a way to do something like the following:
<input type='submit' name='submitActivate' value='Activate' hiddenData='ABC123'></input>
And on the posted page, be able to grab this element's "hiddenData" attribute data?
Upvotes: 0
Views: 640
Reputation: 96
Using a hidden input tag can achieve what you are wanting. You can wrap the button and a hidden input tag in a form like so:
<form onSubmit="doThis(hiddenData)">
<input type='hidden' name='hiddenData' value='ABC123'>
<input type='submit' name='submitActivate' value='Activate'></input>
</form>
Then in JS you can access the hidden input with:
doThis = function(hiddenData) {
console.log(hiddenData.value) //logs ABC123
}
Hope this helps
Upvotes: 1