Hopefully this'll clear up a few elements...
Straight ASP page with VB script, writing in standard HTML for form elements
etc - here's the actual form itself...
This is the version that works, as soon as I ad underscores into the form
and input field names (within the body, and the function itself), it fails!!
----------------------------------------------------------------------------
--------------
<form action="process_clients.asp" method="post" name="formaddnewclient">
<table width="600" height="25" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><img
src="graphics/common/horizontalline_plain.gif" width="600" height="1"></td>
</tr>
</table>
<table width="600" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td align="center" valign="middle"
class="MainTextBody"> </td>
<td> </td>
<td class="MainTextBody"> </td>
</tr>
<tr>
<td width="30" align="center" valign="middle"
class="MainTextBody"><img src="graphics/bullets/medium.gif" width="6"
height="6"></td>
<td width="10"><img src="spacer.gif" width="10"
height="3"></td>
<td class="MainTextBody">Percentage of estimated
turnover</td>
</tr>
</table>
<table width="600" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td width="30" align="center" valign="middle"
class="MainTextBody"> </td>
<td width="10"><img src="spacer.gif" width="10"
height="3"></td>
<td width="125" class="MainTextBody">UK
<input name="QTurnoverPercentUK" type="text"
class="AddAClientTextInput" id="QTurnoverPercentUK"
onChange="javscript:Ash_CalculatePercentageTotal(' formaddnewclient');"
value="0" size="6" maxlength="3">
%</td>
<td width="125" class="MainTextBody">Europe
<input name="QTurnoverPercentEurope" type="text"
class="AddAClientTextInput" id="QTurnoverPercentEurope"
onChange="javscript:Ash_CalculatePercentageTotal(' formaddnewclient');"
value="0" size="6" maxlength="3">
%</td>
<td width="125" class="MainTextBody">Other
<input name="QTurnoverPercentOther" type="text"
class="AddAClientTextInput" id="QTurnoverPercentOther"
onChange="javscript:Ash_CalculatePercentageTotal(' formaddnewclient');"
value="0" size="6" maxlength="3">
%</td>
<td class="MainTextBody"><img src="spacer.gif"
width="178" height="8"></td>
</tr>
</table>
<table width="600" height="25" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><img
src="graphics/common/horizontalline_plain.gif" width="600" height="1"></td>
</tr>
</table>
</form>
----------------------------------------------------------------------------
--------------
....now the function itself
----------------------------------------------------------------------------
--------------
function Ash_SubmitForm(TheFormName) {
eval('document.'+TheFormName+'.submit();')
}
function Ash_CalculatePercentageTotal(TheForm) {
var Num1 = eval('document.'+TheForm+'.QTurnoverPercentUK.valu e');
var Num2 = eval('document.'+TheForm+'.QTurnoverPercentEurope. value');
var Num3 = eval('document.'+TheForm+'.QTurnoverPercentOther.v alue');
if (Num1 > "" && Num2 > "" && Num3 > "") {
if (eval(Number(Num1)+Number(Num2)+Number(Num3)) > 100) {
alert('Please check the percentages entered, they must add up to
100%\n\nIf a region is equal to 0%, please enter a 0');
}
}
}
"Richard Cornford" <ri*****@litotes.demon.co.uk> wrote in message
news:c9**********@sparta.btinternet.com...
J. Hall wrote: The underscores are in the code, the error message received
is that 'the object could not be found' for each of the three
elements, or that it is null - I can assure you the code is
accurate from that point of view.
We can take your word for it that the accompanying HTML corresponds with
your property accessors, in which case you are on your own, or you can
show us the HTML so we can see if there are any obvious reasons for the
failure of your script.
As it stands we don't know which browser is reporting these errors, 'the
object could not be found' doesn't sound like an IE error report. We don
't know whether the HTML is HTML or XHTML (or XHTML being interpreted as
HTML (appendix c compatibility XHTML)). We don't know if the (X?)HTML is
valid. We don't know whether the identifiers in the script are
referencing named form elements of IDed elements (or both). And then
there are numerous other possible factors that might be impacting on
your situation that would just take a moments visual inspection of the
HTML to identify or rule out.
Ultimately your best cause of action is to create a test case page,
stripped down to just the form and accompanying (relevant) script, that
demonstrates the problem. Posting that and allowing us to attempt to
re-produce it in the browser that you are using, and others, will be
your quickest route to understanding the problem. At least partly
because making a striped down test case page often reveals the cause of
the problem along the way (when you discover that stripping something
that seemed irrelevant out coincidentally makes the problem vanish).
Didn't realise I didn't need Eval, ...
<snip>
There are so few genuine reasons for using - eval - that it is better to
assume you don't ever need it. By the time you know enough to encounter
a situation that might call for its use you should be able to be certain
of that for yourself.
Richard.