post the result back to same page??

Ask a Question related to ASP, Design and Development.

  1. #1

    Default post the result back to same page??

    <html>
    <body>
    <Form action="calc.asp" method="post" name="calc">
    <P>NUM1: <input type="text" name="num1">
    <P>NUM2: <input type="text" name="num2">
    <P>RESULT: <input type="text" name="result">
    <P><input type="submit">
    </Form>

    I want to write an ASP page to accept 2 numbers, and return the sum on the
    same page. Can we do it in pure ASP without JavaScript?? It sounds an easy
    problem, and I did that in ASP.NET and JavaScript, but failed in pure ASP
    3.0. Here's the attempts, but definitely not what I want because I want the
    result back to the text field.

    <%
    Dim num1, num2, result
    num1 = CInt(Request.Form("num1"))
    num2 = CInt(Request.Form("num2"))
    result = num1 + num2
    Response.Write("<P>Num1 = " & num1)
    Response.Write("<P>Num2 = " & num2)
    Response.Write("<P>Num3 = " & result)
    %>


    </body>
    </html>


    John Davis Guest

  2. Similar Questions and Discussions

    1. How to Post back page from Client side code?
      Hi, I am developing a website in ASP.NET. I want to have a client side code to confirm the deletion of some information from backend database. I...
    2. #25283 [Fbk->NoF]: SQL Query is pending there, no any result back.
      ID: 25283 Updated by: sniper@php.net Reported By: larry_li at contractor dot amat dot com -Status: Feedback...
    3. Post back
      hello all, I have a simple question. on my .aspx page I have bunch of textbox, and dropdowns. One of the dropdown2 has postback = true. When the...
    4. CSV file uploaded and POST to result page
      "Bela" <aleb@tele2.it> wrote in message news:a0daa249.0307150322.51280175@posting.google.com... Hello again, Bela, If you don't want to just...
    5. Page Post Back -- how to retain selecteditem.value of TWO dropdowns???
      Hi, On Page Load (if not postback), the user selects a choice from dropdownlist1. On SelectedItemChanged for dropdownlist1, dropdownlist2 is...
  3. #2

    Default Re: post the result back to same page??

    If you want the result to be in the text field for the result, you have to
    write the result into the value of that form element as such.


    <%
    Dim num1, num2, result
    num1 = CInt(Request.Form("num1"))
    num2 = CInt(Request.Form("num2"))
    result = num1 + num2
    %>

    <html>
    <body>
    <Form action="calc.asp" method="post" name="calc">
    <P>NUM1: <input type="text" name="num1" value="<%=num1%>">
    <P>NUM2: <input type="text" name="num2" value="<%=num2%>">
    <P>RESULT: <input type="text" name="result" value="<%=result%>">
    <P><input type="submit">
    </Form>




    </body>
    </html>

    Ray at home




    "John Davis" <jrefactor@hotmail.com> wrote in message
    news:#AWIKXyeDHA.2356@TK2MSFTNGP12.phx.gbl...
    > <html>
    > <body>
    > <Form action="calc.asp" method="post" name="calc">
    > <P>NUM1: <input type="text" name="num1">
    > <P>NUM2: <input type="text" name="num2">
    > <P>RESULT: <input type="text" name="result">
    > <P><input type="submit">
    > </Form>
    >
    > I want to write an ASP page to accept 2 numbers, and return the sum on the
    > same page. Can we do it in pure ASP without JavaScript?? It sounds an easy
    > problem, and I did that in ASP.NET and JavaScript, but failed in pure ASP
    > 3.0. Here's the attempts, but definitely not what I want because I want
    the
    > result back to the text field.
    >
    > <%
    > Dim num1, num2, result
    > num1 = CInt(Request.Form("num1"))
    > num2 = CInt(Request.Form("num2"))
    > result = num1 + num2
    > Response.Write("<P>Num1 = " & num1)
    > Response.Write("<P>Num2 = " & num2)
    > Response.Write("<P>Num3 = " & result)
    > %>
    >
    >
    > </body>
    > </html>
    >
    >

    Ray at home Guest

  4. #3

    Default Re: post the result back to same page??

    <%
    dblNum1 = Trim(Request("num1"))
    dblNum2 = Trim(Request("num2"))
    If IsNUmeric(dblNum1) And IsNumeric(dblNum2) Then
    Select Case UCase(Trim(Request("CHOICE")))
    Case "ADD"
    dblAnswer = CDbl(dblNum1) + CDbl(dblNum2)
    Case "SUBTRACT"
    dblAnswer = CDbl(dblNum1) - CDbl(dblNum2)
    Case "MULTIPLY"
    dblAnswer = CDbl(dblNum1) * CDbl(dblNum2)
    Case "DIVIDE"
    dblAnswer = CDbl(dblNum1) / CDbl(dblNum2)
    Case Else
    dblAnswer = ""
    End Select
    End If
    %>
    <html>
    <body>
    <form action="addtest.asp" method="post" name="calc" ID="Form1">
    NUM1: <input type="text" name="num1" value="<%=dblNum1%>"><br>
    NUM2: <input type="text" name="num2" value="<%=dblNum2%>"><br>
    RESULT: <input type="text" name="result" value="<%=dblAnswer%>"><br>
    <input type="submit" name="CHOICE" value="Add">
    <input type="submit" name="CHOICE" value="Subtract">
    <input type="submit" name="CHOICE" value="Multiply">
    <input type="submit" name="CHOICE" value="Divide">
    </form>
    </body>
    </html>


    -dlbjr

    invariable unerring alien


    dlbjr Guest

  5. #4

    Default Re: post the result back to same page??

    yeah, that's what I want, except each text field is filled with 0 before the
    user enters any number. Any workarounds on that??

    "Ray at home" <myfirstname at lane 34 . komm> wrote in message
    news:e#Dc7xyeDHA.3616@TK2MSFTNGP11.phx.gbl...
    > If you want the result to be in the text field for the result, you have to
    > write the result into the value of that form element as such.
    >
    >
    > <%
    > Dim num1, num2, result
    > num1 = CInt(Request.Form("num1"))
    > num2 = CInt(Request.Form("num2"))
    > result = num1 + num2
    > %>
    >
    > <html>
    > <body>
    > <Form action="calc.asp" method="post" name="calc">
    > <P>NUM1: <input type="text" name="num1" value="<%=num1%>">
    > <P>NUM2: <input type="text" name="num2" value="<%=num2%>">
    > <P>RESULT: <input type="text" name="result" value="<%=result%>">
    > <P><input type="submit">
    > </Form>
    >
    >
    >
    >
    > </body>
    > </html>
    >
    > Ray at home
    >
    >
    >
    >
    > "John Davis" <jrefactor@hotmail.com> wrote in message
    > news:#AWIKXyeDHA.2356@TK2MSFTNGP12.phx.gbl...
    > > <html>
    > > <body>
    > > <Form action="calc.asp" method="post" name="calc">
    > > <P>NUM1: <input type="text" name="num1">
    > > <P>NUM2: <input type="text" name="num2">
    > > <P>RESULT: <input type="text" name="result">
    > > <P><input type="submit">
    > > </Form>
    > >
    > > I want to write an ASP page to accept 2 numbers, and return the sum on
    the
    > > same page. Can we do it in pure ASP without JavaScript?? It sounds an
    easy
    > > problem, and I did that in ASP.NET and JavaScript, but failed in pure
    ASP
    > > 3.0. Here's the attempts, but definitely not what I want because I want
    > the
    > > result back to the text field.
    > >
    > > <%
    > > Dim num1, num2, result
    > > num1 = CInt(Request.Form("num1"))
    > > num2 = CInt(Request.Form("num2"))
    > > result = num1 + num2
    > > Response.Write("<P>Num1 = " & num1)
    > > Response.Write("<P>Num2 = " & num2)
    > > Response.Write("<P>Num3 = " & result)
    > > %>
    > >
    > >
    > > </body>
    > > </html>
    > >
    > >
    >
    >

    John Davis Guest

  6. #5

    Default Re: post the result back to same page??

    Just detect if the form has been posted or not.

    <%
    If UCase(Request.ServerVariables("Request_Method")) = "POST" then

    intNum1 = Request.Form("txtNumber1")
    intNum2 = Request.Form("txtNumber2")

    intTotal = intNum1 + intNum2

    Else

    intNum1 = 0
    intNum2 = 0

    End If
    %>
    <html>
    <head>
    </head>
    <body>
    <form method="post">
    <input type="text" name="txtNumber1" value="<%=intNum1%>"><br>
    <input type="text" name="txtNumber2" value="<%=intNum2%>"><br>
    <input type="submit">
    </form>

    <p>
    The total is: <%=intTotal%>
    </p>
    </body>
    </html>




    "John Davis" <jrefactor@hotmail.com> wrote in message
    news:OmZksr0eDHA.1732@TK2MSFTNGP12.phx.gbl...
    : yeah, that's what I want, except each text field is filled with 0 before
    the
    : user enters any number. Any workarounds on that??
    :
    : "Ray at home" <myfirstname at lane 34 . komm> wrote in message
    : news:e#Dc7xyeDHA.3616@TK2MSFTNGP11.phx.gbl...
    : > If you want the result to be in the text field for the result, you have
    to
    : > write the result into the value of that form element as such.
    : >
    : >
    : > <%
    : > Dim num1, num2, result
    : > num1 = CInt(Request.Form("num1"))
    : > num2 = CInt(Request.Form("num2"))
    : > result = num1 + num2
    : > %>
    : >
    : > <html>
    : > <body>
    : > <Form action="calc.asp" method="post" name="calc">
    : > <P>NUM1: <input type="text" name="num1" value="<%=num1%>">
    : > <P>NUM2: <input type="text" name="num2" value="<%=num2%>">
    : > <P>RESULT: <input type="text" name="result" value="<%=result%>">
    : > <P><input type="submit">
    : > </Form>
    : >
    : >
    : >
    : >
    : > </body>
    : > </html>
    : >
    : > Ray at home
    : >
    : >
    : >
    : >
    : > "John Davis" <jrefactor@hotmail.com> wrote in message
    : > news:#AWIKXyeDHA.2356@TK2MSFTNGP12.phx.gbl...
    : > > <html>
    : > > <body>
    : > > <Form action="calc.asp" method="post" name="calc">
    : > > <P>NUM1: <input type="text" name="num1">
    : > > <P>NUM2: <input type="text" name="num2">
    : > > <P>RESULT: <input type="text" name="result">
    : > > <P><input type="submit">
    : > > </Form>
    : > >
    : > > I want to write an ASP page to accept 2 numbers, and return the sum on
    : the
    : > > same page. Can we do it in pure ASP without JavaScript?? It sounds an
    : easy
    : > > problem, and I did that in ASP.NET and JavaScript, but failed in pure
    : ASP
    : > > 3.0. Here's the attempts, but definitely not what I want because I
    want
    : > the
    : > > result back to the text field.
    : > >
    : > > <%
    : > > Dim num1, num2, result
    : > > num1 = CInt(Request.Form("num1"))
    : > > num2 = CInt(Request.Form("num2"))
    : > > result = num1 + num2
    : > > Response.Write("<P>Num1 = " & num1)
    : > > Response.Write("<P>Num2 = " & num2)
    : > > Response.Write("<P>Num3 = " & result)
    : > > %>
    : > >
    : > >
    : > > </body>
    : > > </html>
    : > >
    : > >
    : >
    : >
    :
    :


    Ken Schaefer Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139