Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type mismatch error on function return

Status
Not open for further replies.

stupy1

Programmer
Feb 22, 2002
10
US
Hi guys,

I'm getting a type mismatch error with the following function:

<script type=&quot;text/javascript&quot;>

function checksubmit()
{
var doc = document.methods ;
if (doc.Total_Method_2004.value != 100 || doc.Total_Method_2005.value != 100 || doc.Total_Method_2006.value != 100)
{
alert (&quot;Method distributions must sum to 100%&quot;);
return false;
}
else
{
if (doc.Total_all.value != doc.Target_all.value)
{ alert (&quot;All year totals must equal their target totals.&quot;);
return false;
}
{
return true;
}
}
}
</script>

It's being called here:

<form name=&quot;methods&quot; method=&quot;post&quot; action=&quot;categories.asp&quot; onsubmit=&quot;return checksubmit()&quot;>

I'm able to get into the function and the first alert box &quot;Method Distributions....&quot; but then the error Type mismatch: 'return'

I have no clue what's going on and I have rewritten the function in vbscript and I get the same error. A varation of this function works on all my other pages so there might be a conflict somewhere within this page.

thanks,
stupy
 
in your if statement enclose your values in quotes, they are string values not numeric, so write...

if (doc.Total_Method_2004.value != &quot;100&quot; || doc.Total_Method_2005.value != &quot;100&quot; || doc.Total_Method_2006.value != &quot;100&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top