By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,450 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,450 IT Pros & Developers. It's quick & easy.

Object expected

P: 1
I am getting this error when trying to call the function on textbox onchange. Might be simple but not able to figure out, I am new to asp. Help
<script language="javascript" type="text/javascript;">
<!--
Expand|Select|Wrap|Line Numbers
  1.   function PreTxSoldFor_onchange(x){
  2.         Var MyVar;
  3.         Var ssSQL;
  4.         Var ooRs;
  5.         Var ooCon;
  6.         Set ooCon = Server.CreateObject("ADODB.Connection")
  7.         Set ooRs = Server.CreateObject("ADODB.Recordset")
  8.         ooCon.Open(Application("ConnStr"))
  9.         ssSQL = "SELECT     TOP 100 PERCENT BidItemHeaderId," &_
  10.                 " ROUND(1 - (PreBidMaterialCharge + PreBidMaterialHandingCharge + PreBidConcCharge + PreBidOnSiteLaborCharge + " &_
  11.                 " PreBidBurdenChargeInstall + PreBidDriveCharge + PreBidShopLaborCharge + PreBidBurdenChargeShop " &_
  12.                 " + PreBidOtherCharge) / " & x.value & " " & _
  13.                 ", 2) AS Margin FROM viewPreBid  WHERE     (PreTxSoldFor IS NOT NULL) AND (PreTxSoldFor <> 0) AND " &_
  14.                 " BidItemHeaderId = " & Session("BidItemHeaderID")
  15.     ooRs.Open ssSQL, ooCon, adOpenForwardOnly, adLockOptimistic
  16.  
  17.     if ooRs.Margin < 0.30{
  18.         if getUserName = "mpicard" Or getUserName = "gforshee" or getUserName = "dvenkatesan"{
  19.              MyVar = MsgBox ("Selling below 30% Margin", 0 ,1);}
  20.         else{
  21.             MyVar = MSGBox ("Selling below 30% Margin", 0);}}
  22.     ooRs.Close
  23.     ooCon.Close
  24.     Set ooRs = Nothing
  25.     Set ooCon = Nothing
  26.     if MyVar = 0{
  27.        x.focus();}else continue
  28. }
  29.  
//--></script>


[HTML]<td>Pre-Tax Sold For:</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="tdPreBid">&nbsp;</td>
<td class="tdPreBid">
<input size="10" onchange="javascript:PreTxSoldFor_onchange(this);"
style="text-align:right;" name="PreTxSoldFor" type="text"
value="<%= FormatNumber(IIf(IsNull(oRs("PreTxSoldFor")), 0, oRs("PreTxSoldFor"))) %> " />
</td>
</tr>
<tr>[/HTML]

I get the error at onchange="javascript:PreTxSoldFor_onchange(this);"
Jul 10 '06 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
JavaScript is client-side and ASP is server-side. You can't mix the two together like this.

You can use ASP to generate JavaScript, but you can't run ASP using JavaScript unless you use Ajax, so the solution would be to use Ajax and move your ASP code to an ASP file and call that.

See an example.
Apr 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.