Runat=Server

Results 1 to 5 of 5

Thread: Runat=Server

  1. #1
    Jeff P. Guest

    Default Runat=Server

    Trying to write a script containing a simple Function that will execute at the server. Would like to know if I can do this or am I confused &#060;:-&#124 I keep getting the error "Error: Oject Expected." Here&#039s a code snippet within the HTML page, the page saved as .ASP Any help is GREATLY appreciated!! -Jeff<BR><BR>&#060;form onSubmit=Squareit(5) method="post"&#062;<BR>&#060;INPUT type="submit" value="Testit"&#062;<BR>&#060;/form&#062;<BR><BR>&#060;script language="VBScript" runat=server&#062;<BR> Function Squareit(x)<BR> Dim square<BR> Square = x^2<BR> Response.Write Square<BR> end Function<BR>&#060;/script&#062;<BR>

  2. #2
    taylo Guest

    Default RE: Runat=Server

    Put Squareit in " "<BR>onSubmit="Squareit()"<BR><BR>Do you want to square testit or do you want to square 5 every time?<BR>Maybe it should be<BR><BR>onSubmit="Squareit(testit)"<BR><BR>You should not need a method="post" if the value to <BR>post will be used on the same page. <BR><BR>Try it. Let me know how it goes.<BR><BR>Rob Taylor<BR>taylo@bannerclass.com<BR>www.cartography today.com<BR>

  3. #3
    Jeff P. Guest

    Default RE: Runat=Server

    Thanks for the advice, but to no avail. I&#039ve tried double-quoting all the values without any success. Really what I&#039m trying to do is just pass a value from a form to a sub within a script on the same page as the form, and use the script to redirect the user to another ASP based on that passed value. I just used the function in the previous msg as an example. I&#039d like to use a &#060;script&#062;&#060;/script&#062; within the ASP using VBScript, but have it process at the server side, not client (you know, the browser thing). I&#039ve got a bunch of books, but they don&#039t discuss this well. If you have an example of how to do this, please send me some guidance. Muchly appreciated at this end!!! -Jeff

  4. #4
    Join Date
    Dec 1969
    Posts
    155

    Default RE: Runat=Server

    Jeff:<BR><BR>It works. Here is the source code.<BR>To see what this does, go to<BR>www.cartographytoday.com/sq.asp<BR><BR>You have to remember that when you tell that<BR>to run at the server, you have voided <BR>response.write. Why? Because you have told that<BR>script not to leave the server. You will need<BR>to take taht value from the server and tell it what<BR>page you want it in (i.e. thats the point of runat=server)<BR>Here is the code.<BR>I hope you understand.<BR><BR><BR>&#060;HTML&#062;<BR>&#060;H EAD&#062;<BR>&#060;script language="VBScript"&#062;<BR>Dim x<BR>Public Function Squareit(x)<BR>Dim square<BR>Square = x^2<BR>msgbox Square<BR>end Function<BR>&#060;/script&#062;<BR>&#060;/HEAD&#062;<BR>&#060;BODY&#062;<BR>&#060;form name="sq" onSubmit="Squareit(5)"&#062;<BR>&#060;INPUT type="submit" value="Testit"&#062;<BR>&#060;/form&#062;<BR>&#060;/BODY&#062;<BR>&#060;/HTML&#062;<BR><BR>Rob Taylor<BR>taylo@bannerclass.com<BR>www.cartography today.com


  5. #5
    Jeff P. Guest

    Default RE: Runat=Server

    Rob,<BR><BR>Thanks again for your help! :-)<BR><BR>I suppose that since you didn&#039t have your &#060;script&#062; run at the server, that what I&#039m trying to do is not possible. Also, I really don&#039t need a function since I don&#039t need a return value (my fault). Here&#039s the exact code I&#039m trying to make work (the Response.Redirect does not work, is there a VBScript equivalent??):<BR><BR>&#060;!-- put script in &#060;HEAD&#062;&#060;/HEAD&#062; --&#062;<BR>&#060;!-- call script from onSubmit within a Form, passing the Sub a variable --&#062;<BR><BR>&#060;Script language="vbscript" runat="server"&#062;<BR>Sub Report(report_type)<BR>Select case report_type<BR> Case "reportproj"<BR> Response.Redirect "/reports/reportproj.asp"<BR> Case "reportall"<BR> Response.Redirect "/reports/reportall.asp"<BR>End Select<BR>End Sub<BR>&#060;/script&#062;<BR><BR>Thanks,<BR>-Jeff Paar

Posting Permissions

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