+ Reply to Thread
Results 1 to 9 of 9

Thread: calling javascript function from asp

  1. #1
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    390
    Rep Power
    3

    calling javascript function from asp

    hi i m trying to call client jaavscript function from asp code. see the below code.bold part.
    im getting object expected error.

    Code:
    Response.write  "<TD><select  id=""cboVATCode"& lCounter &""" name=""cboVATCode"& lCounter &"""><script>dd();</script></TD>"
    
    Love is physical attraction and mental destruction

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    There is most likely an error in your JavaScript code. Where does it say 'object expected'? On the actual page or when you double-click the icon in the status bar of Internet Explorer. If it's the latter of the two, then you have a problem in your JavaScript.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    390
    Rep Power
    3

    hi jmh when i double-clicked the icon in the status bar of Internet Explorer then i get error.
    is it possible to call javascript function at server side?
    my function is correct.i m calling this function at diferent places.but when trying to call through asp i m getting error.

    hope it make some sense.
    Code:
    function dd()
    	{
    			if(msVATCodeCombo == '')
    			{
    				msVATCodeCombo += '<option value="S"<%If sDefaultVATCode = "S" Then Response.Write(" selected")%>>S</option>';
    				msVATCodeCombo += '<option value="E"<%If sDefaultVATCode = "E" Then Response.Write(" selected")%>>E</option>';
    				msVATCodeCombo += '<option value="Z"<%If sDefaultVATCode = "Z" Then Response.Write(" selected")%>>Z</option>';
    				msVATCodeCombo += '<option value="L"<%If sDefaultVATCode = "L" Then Response.Write(" selected")%>>L</option>';
    				msVATCodeCombo += '<option value="A"<%If sDefaultVATCode = "A" Then Response.Write(" selected")%>>A</option>';
    				msVATCodeCombo += '<option value="AA"<%If sDefaultVATCode = "AA" Then Response.Write(" selected")%>>AA</option>';
    				msVATCodeCombo += '<option value="AB"<%If sDefaultVATCode = "AB" Then Response.Write(" selected")%>>AB</option>';
    				msVATCodeCombo += '<option value="AC"<%If sDefaultVATCode = "AC" Then Response.Write(" selected")%>>AC</option>';
    				msVATCodeCombo += '<option value="B"<%If sDefaultVATCode = "B" Then Response.Write(" selected")%>>B</option>';
    				msVATCodeCombo += '<option value="C"<%If sDefaultVATCode = "C" Then Response.Write(" selected")%>>C</option>';
    				msVATCodeCombo += '<option value="G"<%If sDefaultVATCode = "G" Then Response.Write(" selected")%>>G</option>';
    				msVATCodeCombo += '<option value="H"<%If sDefaultVATCode = "H" Then Response.Write(" selected")%>>H</option>';
    				msVATCodeCombo += '<option value="O"<%If sDefaultVATCode = "O" Then Response.Write(" selected")%>>O</option>';
    				msVATCodeCombo += '</select>';
    			}
    }
    
    Love is physical attraction and mental destruction

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    Using ASP, it is possible to write JavaScript to the page, but not actually call it. Are you sure the function is available to the page? Are you including it or copying and pasting it to each page?
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  5. #5
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    390
    Rep Power
    3

    yes function is in <scrip></script> section in head.
    Love is physical attraction and mental destruction

  6. #6
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    I'm trying to reproduce your error, but it says 'msVATCodeCombo' is undefined. How are you defining this so I may test?
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  7. #7
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    390
    Rep Power
    3

    hi
    Code:
    	<script type="text/javascript">
    		var mbSubmitting = false;
    		var msUOMDropdown = '';
    		var msVATCodeCombo = ''; 
    declared as global varaible.
    Love is physical attraction and mental destruction

  8. #8
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    Guddu,

    Here's a test I ran that worked using your function:

    Code:
    <html>
        <head>
            <% Dim sDefaultVATCode, lCount
               sDefaultVATCode = "S"
               lCount = 3
            %>
            <script language="javascript" type="text/javascript">
            <!--
            var msVATCodeCombo = '';
            function dd()
     {
         if(msVATCodeCombo == '')
       {
           msVATCodeCombo += '<option value="S"<%If sDefaultVATCode = "S" Then Response.Write(" selected")%>>S</option>';
           msVATCodeCombo += '<option value="E"<%If sDefaultVATCode = "E" Then Response.Write(" selected")%>>E</option>';
           msVATCodeCombo += '<option value="Z"<%If sDefaultVATCode = "Z" Then Response.Write(" selected")%>>Z</option>';
           msVATCodeCombo += '<option value="L"<%If sDefaultVATCode = "L" Then Response.Write(" selected")%>>L</option>';
           msVATCodeCombo += '<option value="A"<%If sDefaultVATCode = "A" Then Response.Write(" selected")%>>A</option>';
           msVATCodeCombo += '<option value="AA"<%If sDefaultVATCode = "AA" Then Response.Write(" selected")%>>AA</option>';
           msVATCodeCombo += '<option value="AB"<%If sDefaultVATCode = "AB" Then Response.Write(" selected")%>>AB</option>';
           msVATCodeCombo += '<option value="AC"<%If sDefaultVATCode = "AC" Then Response.Write(" selected")%>>AC</option>';
           msVATCodeCombo += '<option value="B"<%If sDefaultVATCode = "B" Then Response.Write(" selected")%>>B</option>';
           msVATCodeCombo += '<option value="C"<%If sDefaultVATCode = "C" Then Response.Write(" selected")%>>C</option>';
           msVATCodeCombo += '<option value="G"<%If sDefaultVATCode = "G" Then Response.Write(" selected")%>>G</option>';
           msVATCodeCombo += '<option value="H"<%If sDefaultVATCode = "H" Then Response.Write(" selected")%>>H</option>';
           msVATCodeCombo += '<option value="O"<%If sDefaultVATCode = "O" Then Response.Write(" selected")%>>O</option>';
           msVATCodeCombo += '</select>';
       }
     document.write(msVATCodeCombo);
            }
            //-->
            </script>
        </head>
        <body>
            <%
                Response.Write "<select id=""cboVATCode" & lCount & """ name=""cboVATCode" & lCount & """><script language=""javascript"" type=""text/javascript"">dd();</script>"
            %>
        </body>
    </html>
    
    I had to simulate some of your variables (e.g. lCount and sDefaultVATCode) and I had to add this line to your function:

    Code:
    document.write(msVATCodeCombo);
    
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  9. #9
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    390
    Rep Power
    3

    yes my dear thats did the trick.
    Thanks a lot.i would be more happy if some suggestion for my another thread.
    Love is physical attraction and mental destruction

+ Reply to Thread

Similar Threads

  1. calling function
    By guddu in forum ASP Development
    Replies: 3
    Last Post: November 5th, 2008, 09:34 AM
  2. JavaScript Date & Time Display
    By jmurrayhead in forum JavaScript Code Samples
    Replies: 0
    Last Post: August 13th, 2008, 08:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO