awebguynow wrote:
in other words, Can I make client side mod's before I submit a form and
Post ?
I understood the Subject better:
| Can I submit only Changed values of form
Yes, you can. Provided, that client-side scripting is enabled and the DOM
provides the necessary means. I would consider that use of client-side
scripting to be a Good Thing. However, you should not rely on it when
processing the submitted data server-side.
I guess its just a matter of cycling through the form elements and
setting value to null (or empty string) for those that did not Change (
using onChange ).
No, since `input' element's values are strings, setting them to null (type
`object') is likely to be unsuccessful, and setting the value to the empty
string will submit that name-value pair anyway as something matching
"[&?]name=", where `name' is the name of the `input' element.
What you can do is to iterate through the elements collection and where you
find an object that has the `value' and the `defaultValue' properties, and
the value of `value' is equal to the value of `defaultValue', you can
disable that the respective control. Quickhack:
<script type="text/javascript">
function submitChanged(f)
{
if (f && f.elements)
{
for (var i = f.elements.length; i--;)
{
var o = f.elements[i];
if (o.tagName.toLowerCase() == "input"
&& o.value == o.defaultValue
&& (!o.disabled || o.disabled.toLowerCase() == "disabled"))
{
if (!(o.disabled = true))
{
o.disabled = "disabled";
}
}
}
}
return true;
}
</script>
<form ... onsubmit="return submitChanged(this);">
...
</form>
The problem with this solution is if the Back feature of the UA is used, the
elements previously disabled on submit will probably stay disabled until
the document is reloaded.
HTH
PointedEars