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 ...
| |||||||
|
#1
| ||||
| ||||
| 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
| ||||
| ||||
| 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 |
|
#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>';
}
}
|
|
#4
| ||||
| ||||
| 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? |
|
#5
| ||||
| ||||
| yes function is in <scrip></script> section in head. |
|
#7
| ||||
| ||||
| hi Code: <script type="text/javascript"> var mbSubmitting = false; var msUOMDropdown = ''; var msVATCodeCombo = ''; |
|
#8
| ||||
| ||||
| 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>
Code: document.write(msVATCodeCombo); |
| The Following User Says Thank You to jmurrayhead For This Useful Post: | ||
guddu (November 19th, 2008) | ||
|
#9
| ||||
| ||||
| yes my dear thats did the trick. Thanks a lot.i would be more happy if some suggestion for my another thread. |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |