[Javascript] multiple onSubmit events not working

Ed Curtis ed at homes2see.com
Thu Sep 1 04:22:49 CDT 2005


I'm attempting to clear three functions with a single onSubmit form event.

<form name="form" action="dothis.php" method="post" onSubmit="return
check_upload_required(); openpopup(); submitonce(this);">

The check_upload_required function works as expected but the script never
executes the openpopup() or submitonce(this) functions. If I remove the
check_upload_required() from the onSubmit event the other functions work
as expected. Can anyone shed some light on why this is happening. I really
need for all three functions to work together.

Thanks,

Ed

The code for each function follows:

<script language="JavaScript">
<!--

function check_upload_required() {

if (document.form.filename.value.length == 0) {
        alert("Please choose an image to upload.\n");
        return false;

        }

}
//-->

</script>

<script>

//Popup Window Script
//By JavaScript Kit (http://javascriptkit.com)
//JavaScript tutorials and over 400+ free scripts

function openpopup(){

var popurl="progress.html"

wint = 0;
winl = 0;
if (screen) {
winl = (screen.width / 2) - 200;
wint = (screen.height / 2) - 150;
}
winpops=window.open(popurl,"popupwin","width=250,height=170,top='+wint+',left='+winl+',")

}

</script>

<script>

function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and
"reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}

</script>






More information about the Javascript mailing list