W
William Gill
I dusted off an old JS reference (it's been years) to work on a HTML
database edit app, and have a couple of questions. I have noticed that
form action="javascript:myscript(this)" and onSubmit="myscript(this)"
send different objects to the script. I think IE and Firefox get
different objects (Maybe the document object and window object ?) from
the action=, but both seem to get the form object from onSubmit. Can
anyone expound on what I'm seeing? Is there a good way to see exactly
what object myscript(this) gets? I have cobbled a "dump to popup window
routine", but it's pretty crude.
Also, I'm not actually submitting the form. I plan to use Ajax to
communicate with the server. I change the style of input objects via
onChange, to let users know an item has been edited, but not updated in
the db. The user can update a single changed field in the db via
onDblClick(), or update all changed fields in a table (each table's
fields are in a form on the page) by clicking a button. Here again I'm
having problems. A reset button works exactly as advertised, but I'm
having a couple of problems with the other buttons like "Update All" and
"Delete Record." The first problem is determining which button was
clicked. I could use each button's onClick=myscript(this) property then
in myscript(caller) use caller.name to see which button then caller.form
to get the form's elements collection, loop through them checking for
className == "changed", and process the data, but this seems a long way
around. Lastly, if I "submit" the form by either making the button type
submit (or by hitting return from within the form) it results in the
displayed forms being reset to original hard coded (by PHP))value=
values. The only way I seem to avoid this is setting form
action="javascript:noop(), where noop() is an empty function like:
function noop(){}
Any thoughts or input are appreciated.
database edit app, and have a couple of questions. I have noticed that
form action="javascript:myscript(this)" and onSubmit="myscript(this)"
send different objects to the script. I think IE and Firefox get
different objects (Maybe the document object and window object ?) from
the action=, but both seem to get the form object from onSubmit. Can
anyone expound on what I'm seeing? Is there a good way to see exactly
what object myscript(this) gets? I have cobbled a "dump to popup window
routine", but it's pretty crude.
Also, I'm not actually submitting the form. I plan to use Ajax to
communicate with the server. I change the style of input objects via
onChange, to let users know an item has been edited, but not updated in
the db. The user can update a single changed field in the db via
onDblClick(), or update all changed fields in a table (each table's
fields are in a form on the page) by clicking a button. Here again I'm
having problems. A reset button works exactly as advertised, but I'm
having a couple of problems with the other buttons like "Update All" and
"Delete Record." The first problem is determining which button was
clicked. I could use each button's onClick=myscript(this) property then
in myscript(caller) use caller.name to see which button then caller.form
to get the form's elements collection, loop through them checking for
className == "changed", and process the data, but this seems a long way
around. Lastly, if I "submit" the form by either making the button type
submit (or by hitting return from within the form) it results in the
displayed forms being reset to original hard coded (by PHP))value=
values. The only way I seem to avoid this is setting form
action="javascript:noop(), where noop() is an empty function like:
function noop(){}
Any thoughts or input are appreciated.