Object expected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saidhanu
    New Member
    • Jul 2006
    • 1

    Object expected

    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="javas cript" type="text/javascript;">
    <!--
    [CODE=javascript] function PreTxSoldFor_on change(x){
    Var MyVar;
    Var ssSQL;
    Var ooRs;
    Var ooCon;
    Set ooCon = Server.CreateOb ject("ADODB.Con nection")
    Set ooRs = Server.CreateOb ject("ADODB.Rec ordset")
    ooCon.Open(Appl ication("ConnSt r"))
    ssSQL = "SELECT TOP 100 PERCENT BidItemHeaderId ," &_
    " ROUND(1 - (PreBidMaterial Charge + PreBidMaterialH andingCharge + PreBidConcCharg e + PreBidOnSiteLab orCharge + " &_
    " PreBidBurdenCha rgeInstall + PreBidDriveChar ge + PreBidShopLabor Charge + PreBidBurdenCha rgeShop " &_
    " + PreBidOtherChar ge) / " & x.value & " " & _
    ", 2) AS Margin FROM viewPreBid WHERE (PreTxSoldFor IS NOT NULL) AND (PreTxSoldFor <> 0) AND " &_
    " BidItemHeaderId = " & Session("BidIte mHeaderID")
    ooRs.Open ssSQL, ooCon, adOpenForwardOn ly, adLockOptimisti c

    if ooRs.Margin < 0.30{
    if getUserName = "mpicard" Or getUserName = "gforshee" or getUserName = "dvenkatesa n"{
    MyVar = MsgBox ("Selling below 30% Margin", 0 ,1);}
    else{
    MyVar = MSGBox ("Selling below 30% Margin", 0);}}
    ooRs.Close
    ooCon.Close
    Set ooRs = Nothing
    Set ooCon = Nothing
    if MyVar = 0{
    x.focus();}else continue
    }
    [/CODE]//--></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="javas cript:PreTxSold For_onchange(th is);"
    style="text-align:right;" name="PreTxSold For" type="text"
    value="<%= FormatNumber(II f(IsNull(oRs("P reTxSoldFor")), 0, oRs("PreTxSoldF or"))) %> " />
    </td>
    </tr>
    <tr>[/HTML]

    I get the error at onchange="javas cript:PreTxSold For_onchange(th is);"
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.

    Comment

    Working...