Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / November 2003

Tip: Looking for answers? Try searching our database.

How can I pass parameter to a function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DS - 24 Nov 2003 11:33 GMT
I just get a input from another form, then pass it to a JS
function, but it causes error, pls help to solve it.
Thanks.

ATtached pls find the simple program:

<%@ LANGUAGE=JavaScript %>
<HTML>
<HEAD><TITLE>Sybase Web DataWindow</TITLE>

function jsFunction(str_arg)
{
  return str_arg.substr(1,1)       
}

</HEAD>
<BODY>

<%
   str_Item= Request.Form("Item")
   result = jsFunction(str_Item)
   Response.Write(result)
%>

</BODY>
</HTML
Steve Fulton - 24 Nov 2003 12:01 GMT
> I just get a input from another form, then pass it to a JS
> function, but it causes error, pls help to solve it.
[quoted text clipped - 10 lines]
>    return str_arg.substr(1,1)
> }

What is this function? If it's supposed to be executed on the server, it should
be enclosed in <% %> delimiters. If it's supposed to be executed on the client,
it should be enclosed in <script> </script> tags *and* it can't be called by
your server-side code later on. As it is now, the code is simply an anonymous
block inside the page's head element, where it's invalid markup.

> </HEAD>
> <BODY>
[quoted text clipped - 7 lines]
> </BODY>
> </HTML>

Signature

Steve

Authority without wisdom is like a heavy axe without an edge, fitter to bruise
than polish. -Anne Bradstreet

- 24 Nov 2003 16:15 GMT
But, how can I pass arguments to other functions, which
may be outside of <% %>?

Daniel

>-----Original Message-----
>> I just get a input from another form, then pass it to a JS
[quoted text clipped - 29 lines]
>> </BODY>
>> </HTML>
Steve Fulton - 24 Nov 2003 18:35 GMT
[quoting fixed]

>>> I just get a input from another form, then pass it to a JS
>>> function, but it causes error, pls help to solve it.
[quoted text clipped - 29 lines]
>>> </BODY>
>>> </HTML>

> But, how can I pass arguments to other functions, which
> may be outside of <% %>?

You don't have a function called jsFunction! The 'function' isn't enclosed in
<script> </script> tags or <% %> delimiters; it's just text, not code!

Your server-side code seems to expect a return value from jsFunction. If the
function is supposed to execute on the client, you can't do this. Code on the
sever executes first. The output from this code (including client-side
functions) is sent to the client, where it is parsed. Only then do client-side
functions exist as executable code--after the server-side code is destroyed!

Signature

Steve

Failures are divided into two classes--those who thought and never did, and
those who did and never thought. -John Charles Salak


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.