Hello @ all!
When I use the manger and edit a snippet for example, hit "save", the complete form input elements are disabled but the data is still sent.
I want to add this to a snippet but it’s not working as supposed. Generally, when you set a form or input field as disabled, it’s value is not submitted, but in the manger it is.
From the source code I could grab this:
function saveWait(fName) {
document.getElementById("savingMessage").innerHTML = "Saving, please wait...";
for(i = 0; i < document.forms[fName].elements.length; i++) {
document.forms[fName].elements[i].disabled='disabled';
}
}
Now I have for example a simple page like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Test</title>
<script language="javascript" type="text/javascript">
/* <![CDATA[ */
function saveWait(fName) {
document.getElementById("savingMessage").innerHTML = "Saving, please wait...";
for(i = 0; i < document.forms[fName].elements.length; i++) {
document.forms[fName].elements[i].disabled='disabled';
}
}
/* ]]> */
</script>
</head>
<body>
<?php
foreach ($_POST as $key => $value)
echo "{$key} = {$value}<br />";
?>
<span class="warning" id='savingMessage'></span>
<form method="post" name="test" onsubmit="saveWait('test');">
<input type="text" name="Name" size="40" maxlength="255" /><br />
<input type="text" name="Email" size="40" maxlength="255" /><br />
<input type="submit" name="Submit" value="submit" />
</form>
</body>
</html>
The JavaScript disables nicely the form, but I get no values back. How is MODx manager doing this? If I remove the JavaScript the form is submitting good.
Thank you very much!
Regards, Boby.