DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

calling javascript function from asp

This is a discussion on calling javascript function from asp within the ASP Development forums, part of the Programming & Scripting category; hi i m trying to call client jaavscript function from asp code. see the below code.bold part. im getting object ...

Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

  #1  
Old November 19th, 2008, 11:07 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default 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
Reply With Quote
  #2  
Old November 19th, 2008, 11:21 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,953
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

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 with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
  #3  
Old November 19th, 2008, 11:26 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

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>';
			}
}
Reply With Quote
  #4  
Old November 19th, 2008, 11:45 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,953
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

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?
Reply With Quote
  #5  
Old November 19th, 2008, 11:48 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

yes function is in <scrip></script> section in head.
Reply With Quote
  #6  
Old November 19th, 2008, 12:01 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,953
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

I'm trying to reproduce your error, but it says 'msVATCodeCombo' is undefined. How are you defining this so I may test?
Reply With Quote
  #7  
Old November 19th, 2008, 12:03 PM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

hi
Code:
	<script type="text/javascript">
		var mbSubmitting = false;
		var msUOMDropdown = '';
		var msVATCodeCombo = ''; 
declared as global varaible.
Reply With Quote
  #8  
Old November 19th, 2008, 12:19 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,953
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

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);

Comments on this post
guddu agrees: Thanked Post
Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
guddu (November 19th, 2008)
  #9  
Old November 19th, 2008, 02:48 PM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

yes my dear thats did the trick.
Thanks a lot.i would be more happy if some suggestion for my another thread.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
calling function guddu ASP Development 3 November 5th, 2008 09:34 AM
JavaScript Date & Time Display jmurrayhead JavaScript Code Samples 0 August 13th, 2008 08:46 PM


All times are GMT -4. The time now is 10:22 PM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2