PDA

View Full Version : onsubmit in code



why not
09-21-2008, 06:51 AM
hi ! i have any code for lightbox ! this worked with : onclick="loadingPanel.show()
now i have other code for enable or disable content with java script ;


<script language="javascript" type="text/javascript">
var the_form = window.document.LISTFORM;
var filter_form = window.document.FILTERFORM;

select_list("{FSTATUS}", filter_form.fstatus);
select_list("{FARCHIVED}", filter_form.farchived);
select_list("{FCAT_ID}", filter_form.fcat_id);

function updateForm(the_url){
if ( !is_checked_item(the_form) ){
alert('CHOOSE_ITEM');
}
else{
the_form.action = the_url;
the_form.submit();
}
}

function deleteForm(the_url){
if ( !is_checked_item(the_form) ){
alert('CHOOSE_ITEM');
}
else{
if ( confirm('YES or NO') ){
the_form.action = the_url;
the_form.submit();
}
}
}
</script>
now ! how to add onclick or onsubmit in javascript code ?? NOTE : not add onclick in form ! after click Yes onclick="loadingPanel.show()

thanks

Nile
09-22-2008, 03:34 AM
Can you use proper grammar please, I didn't understand a sentence you said. Sorry if that offends you.

magicyte
09-27-2008, 01:52 AM
DD Member, might I ask that you not post threads that do not ask for help. If you want to do this, please post the thread in the Lounge.

This is just telling you that you must post things that have no specific meaning for people to help you in the Lounge.

Just saying. Note that this is important.

But, okay. Nice code!! :D

-magicyte

jscheuer1
09-27-2008, 01:59 PM
how to add onclick or onsubmit in javascript code ?? NOTE : not add onclick in form ! after click Yes onclick="loadingPanel.show()

Well, say your form is (as you defined it):



var the_form = window.document.LISTFORM;

Which should be the same as (the preferred):


var the_form = document.forms['LISTFORM'];

Then you can:


the_form.onsubmit = function(){
code here to run on submit;
};

Or, if you already have defined a function that requires no arguments, like say - loadingPanel.show(); - then you can do:


the_form.onsubmit = loadingPanel.show;

Note: When doing it this second way, you cannot use () or any arguments, and the event object will be passed as the first argument to the function, except in IE, where it will be available as window.event if needed.