passing form elements from page to page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abby Lee

    passing form elements from page to page

    My code works but because I'm using VBscript within JavaScript I get an error
    message...the yellow tri-angle with an "!" mark.

    ---------------within my body-------------
    <script language="JavaS cript">document .write(formatCu rrency(<%=Reque st.Form
    ("total")%>) )</script>
    ------------------------------------------
    My script takes the form element "total" from the previous page and sends it
    to a function for formatting. Problem is...JavaScrip just doesn't like
    VBscript. How do I get the form element using JavaScript?
  • kaeli

    #2
    Re: passing form elements from page to page

    In article <uiucguest.2004 1028123313$787e @news.ks.uiuc.e du>, abbylee26
    @hotmail.com enlightened us with...[color=blue]
    > My code works but because I'm using VBscript within JavaScript[/color]

    Not because.
    Javascript can call client-side vbscript just fine, if it's done right and IE
    is the browser. See code below.
    [color=blue]
    >
    > ---------------within my body-------------
    > <script language="JavaS cript">document .write(formatCu rrency(<%=Reque st.Form
    > ("total")%>) )</script>
    > ------------------------------------------
    > My script takes the form element "total" from the previous page and sends it
    > to a function for formatting. Problem is...JavaScrip just doesn't like
    > VBscript. How do I get the form element using JavaScript?
    >[/color]

    You don't. It has nothing to do with getting the form element. The form
    element is gotten via ASP server-side VBscript. You are calling this function
    as though it is client-side.

    Is formatCurrency a client-side vbscript function you wrote? If not, this is
    the wrong syntax to use (it needs to be in the <%= %> construct as well). If
    so, check that it returns a string, as expected by document.write.

    If it is a server-side function (one defined in your ASP), do this: (note the
    quotes! they are important.)

    document.write( "<%= formatCurrency( Request.Form ("total") %>")

    If it is a client-side function:
    Client-side example (IE ONLY):
    This works fine in IE. So, it's something you're doing wrong.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title> New Document </title>
    <script type="text/vbscript">
    Function sayHi (str)
    sayHi = "Hi!" & str
    End Function
    </script>
    </head>

    <body>
    <script type="text/javascript">
    document.write( sayHi("Whee!")) ;
    </script>
    </body>
    </html>

    --
    --
    ~kaeli~
    Shotgun wedding: A case of wife or death.



    Comment

    • Fred Oz

      #3
      Re: passing form elements from page to page

      Abby Lee wrote:[color=blue]
      > My code works but because I'm using VBscript within JavaScript I get an error
      > message...the yellow tri-angle with an "!" mark.
      >
      > ---------------within my body-------------
      > <script language="JavaS cript">document .write(formatCu rrency(<%=Reque st.Form
      > ("total")%>) )</script>
      > ------------------------------------------
      > My script takes the form element "total" from the previous page and sends it
      > to a function for formatting. Problem is...JavaScrip just doesn't like
      > VBscript. How do I get the form element using JavaScript?[/color]

      Just in case you are client-side and still want to get the form value...

      <body>
      <p>The button can use 'this.form' because it belongs to the same form
      as the text area it's trying to get the value of.</p>
      <p>The link uses document.forms because it's external to the form - and
      AFAIK <a> tags can't be children of forms.</p>

      <form name="theForm" action="">
      <input type="text" name="total" cols="20">
      <input type="button" value="Show text"
      onclick="alert( 'You entered: ' + this.form.total .value);">
      <input type="reset">
      </form>
      <p><a href="#"
      onclick="alert( 'You entered: '
      + document.forms['theForm'].elements['total'].value);">Show
      text</a> using a link.</p>

      </body>

      Fred.

      Comment

      • McKirahan

        #4
        Re: passing form elements from page to page

        "Abby Lee" <abbylee26@hotm ail.com> wrote in message
        news:uiucguest. 20041028123313$ 787e@news.ks.ui uc.edu...[color=blue]
        > My code works but because I'm using VBscript within JavaScript I get an[/color]
        error[color=blue]
        > message...the yellow tri-angle with an "!" mark.
        >
        > ---------------within my body-------------
        > <script[/color]
        language="JavaS cript">document .write(formatCu rrency(<%=Reque st.Form[color=blue]
        > ("total")%>) )</script>
        > ------------------------------------------
        > My script takes the form element "total" from the previous page and sends[/color]
        it[color=blue]
        > to a function for formatting. Problem is...JavaScrip just doesn't like
        > VBscript. How do I get the form element using JavaScript?[/color]


        This works for me (on an IE browser).

        <html>
        <head>
        <title>jsandvbs .ht</title>
        <script type="text/vbscript">
        Function Money(amount)
        Money = FormatCurrency( amount)
        End Function
        </script>
        </head>
        <body>
        <script type="text/javascript">
        var money = Money(1234.56);
        document.write( money);
        </script>
        </body>
        </html>


        Comment

        Working...