Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1708 How can I pass the value of a hidden field into a confirm dialog box when the submit button is pressed, so I can ask the user if they really want to edit/remove the visible version of the hidden value?

irt.org | Knowledge Base | JavaScript | Form | Q1708 [ previous next ]

Q1708 How can I pass the value of a hidden field into a confirm dialog box when the submit button is pressed, so I can ask the user if they really want to edit/remove the visible version of the hidden value?

Try:

<html>

<head>

<script language="JavaScript"><!--
function validate() {
  if (document.myForm.hidden.value != document.myForm.visible.value)
    return confirm('Is this the correct value: ' + document.myForm.visible.value);
  return true;
}
//--></script>

</head>

<body>

<form name="myForm" onSubmit="validate()">
<input type="hidden" name="hidden" value="Hello world">
<input type="text" name="visible" value="Hello world">
<input type="submit" value="Submit">
</form>

<script language="JavaScript"><!--
// reset visible form field in case user pages back to this page
document.myForm.visible.value = document.myForm.hidden.value;
//--></script>

</body>

</html>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.