Jump to content

Multiple Scripts but only one works


Recommended Posts

Hi! I have multiple scripts for a submission page. When I execute the page I am only able to get one to work at a time. Not all three. I am not sure what I am doing wrong. Any help or advice would be appreciated. I have pasted the scripts below. I have all the scripts in the footer of the page.

The first simply checks that the MOQ field is greater than the Inner Pack field.

The second checks that cost is less than retail.

They third, if the virtual check box is checked, it will copy the data from the Vendor VPN field to the Vendor Style field.

<SCRIPT LANGUAGE="JavaScript">

 function check()
 {
   var v_moq = parseFloat(document.getElementById("InsertRecordMOQ").value);
 var v_innerpack = parseFloat(document.getElementById("InsertRecordINNERPACK").value);
   
if(v_moq<v_innerpack) {
     window.alert("MOQ Must Be Less Than The Inner Pack");
 return false;
}

}

 document.getElementById("caspioform").onsubmit=check;

</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">

 function check()
 {
   var v_cost = parseFloat(document.getElementById("InsertRecordCOST").value);
 var v_retail = parseFloat(document.getElementById("InsertRecordRETAIL").value);
   
if(v_cost>v_retail) {
     window.alert("Vendor Cost must be less than Retail");
 return false;
}

}

 document.getElementById("caspioform").onsubmit=check;

</SCRIPT>
<script>
function f_vendorstyle()
{
    if(document.getElementById('cbParamVirtual1').checked)
     {
  document.getElementById('InsertRecordVENDORSTYLE').value=document.getElementById('InsertRecordVENDORVPN').value;

} else {
document.getElementById('InsertRecordVENDORSTYLE').value="";

}


}
document.getElementById('cbParamVirtual1').onclick= f_vendorstyle;
</script>

 

Link to comment
Share on other sites

Hi Twired, 

 

I don't know that I am javascript savvy enough to get this into my form. I updated the scripts above to distinct function names, so I have checkCOST and checkMOQ. Based on my understanding of the articles you gave I added :<form onsubmit="return ((checkCOST() & checkMOQ()) == 1)"> to my footer but I am not able to get anything to work. I did determine that the third script "f_vendorstyle" was acting correctly and was not required in the onsubmit validation.

 

Any additional assistance or guidance would be most appreciated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...