forms question

Discussion in 'ASP General' started by Freeserve, Oct 3, 2003.

  1. Freeserve

    Freeserve Guest

    Hi,
    I have a form with some fields and a submit button. The submit button posts
    the results to itself, which are then processed. I have 2 questions:

    1. Is it possible to have a series of button each of which changes one of
    the items posted and then posts the form?
    2. Is it possible to cause a "processing" banner to be displayed until the
    page gets refreshed?

    Thanks.
    Freeserve, Oct 3, 2003
    #1
    1. Advertising

  2. Freeserve

    Bob Barrows Guest

    Freeserve wrote:
    > Hi,
    > I have a form with some fields and a submit button. The submit
    > button posts the results to itself, which are then processed. I have
    > 2 questions:
    >
    > 1. Is it possible to have a series of button each of which changes
    > one of the items posted and then posts the form?


    Sure. This is a client-side code question and should have been posted to one
    of the dhtml groups, but, assuming you;ve set the form's id property to
    "myForm":
    1. give your textbox an id (set its id property), say id="txt1"
    2. give the button that controls that textbox a unique id, say id="cmd1"
    3. In a script block, create a cmd1_onclick sub if you are using vbscript,
    or function if jscript. Write the code to set the textbox's value property:
    myForm.txt1.value = "something"
    and call the form's submit method:
    vbscript:
    myForm.submit
    jscript:
    myForm.submit()

    This is your last free pass :)
    In the future submit client-side code questions to the appopripriate
    newsgroup and indicate which script language you intend to use.

    > 2. Is it possible to cause a "processing" banner to be displayed
    > until the page gets refreshed?
    >

    There is a method which sometimes works, sometimes doesn't. It requires a
    combination of server-side and client-side code:
    Make sure buffering is on and then use response.flush to display your
    message. Then do your processing and hide the message in the window's onload
    event. Here is an example:

    <%@ Language=VBScript %>
    <%
    Response.Buffer=true
    %>
    <%
    if len(Request.Form("text1")) > 0 then
    Response.Write "<div id=""divPrc"">Processing</div>"
    Response.Flush
    dim t
    t=now
    t=dateadd("s",3,t)
    do until now > t
    loop
    else
    //we need the div to be there - this message will never be seen
    Response.Write "<div id=""divPrc"">" & "Nothing to process" & "</div>"
    Response.Flush
    end if
    %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--

    function window_onload() {
    divPrc.style.display="none";
    /*the following line is optional - do not use this if you are submitting
    to another page*/
    MyForm.action=window.location;
    }

    //-->
    </SCRIPT>
    </HEAD>
    <BODY LANGUAGE=javascript onload="return window_onload()">

    <form id="MyForm" method="post">
    Enter some text and click submit:
    <INPUT type="text" id=text1 name=text1>
    <INPUT type="submit" value="Submit" id=submit1 name=submit1>
    </form>

    </BODY>
    </HTML>
    Bob Barrows, Oct 3, 2003
    #2
    1. Advertising

  3. Freeserve

    Bob Barrows Guest

    Correction:
    <%@ Language=VBScript %>
    <%
    Response.Buffer=true
    %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--

    function window_onload() {
    divPrc.style.display="none";
    /*the following line is optional - do not use this if you are submitting
    to another page*/
    MyForm.action=window.location;
    }

    //-->
    </SCRIPT>
    </HEAD>
    <BODY LANGUAGE=javascript onload="return window_onload()">
    <%
    if len(Request.Form("text1")) > 0 then
    Response.Write "<div id=""divPrc"">Processing</div>"
    Response.Flush
    dim t
    t=now
    t=dateadd("s",3,t)
    do until now > t
    loop
    else
    //we need the div to be there - this message will never be seen
    Response.Write "<div id=""divPrc"">" & "Nothing to process" & "</div>"
    Response.Flush
    end if
    %>

    <form id="MyForm" method="post">
    Enter some text and click submit:
    <INPUT type="text" id=text1 name=text1>
    <INPUT type="submit" value="Submit" id=submit1 name=submit1>
    </form>

    </BODY>
    </HTML>
    Bob Barrows, Oct 3, 2003
    #3
  4. Freeserve

    Freeserve Guest

    Thanks for the info. I will try and get the correct group next time!

    "Bob Barrows" <> wrote in message
    news:...
    > Correction:
    > <%@ Language=VBScript %>
    > <%
    > Response.Buffer=true
    > %>
    > <HTML>
    > <HEAD>
    > <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    > <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    > <!--
    >
    > function window_onload() {
    > divPrc.style.display="none";
    > /*the following line is optional - do not use this if you are submitting
    > to another page*/
    > MyForm.action=window.location;
    > }
    >
    > //-->
    > </SCRIPT>
    > </HEAD>
    > <BODY LANGUAGE=javascript onload="return window_onload()">
    > <%
    > if len(Request.Form("text1")) > 0 then
    > Response.Write "<div id=""divPrc"">Processing</div>"
    > Response.Flush
    > dim t
    > t=now
    > t=dateadd("s",3,t)
    > do until now > t
    > loop
    > else
    > //we need the div to be there - this message will never be seen
    > Response.Write "<div id=""divPrc"">" & "Nothing to process" & "</div>"
    > Response.Flush
    > end if
    > %>
    >
    > <form id="MyForm" method="post">
    > Enter some text and click submit:
    > <INPUT type="text" id=text1 name=text1>
    > <INPUT type="submit" value="Submit" id=submit1 name=submit1>
    > </form>
    >
    > </BODY>
    > </HTML>
    >
    >
    >
    >
    Freeserve, Oct 3, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brendan Miller

    Web Forms VS Windows Forms

    Brendan Miller, Aug 11, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,068
    Kevin Spencer
    Aug 11, 2003
  2. Eric
    Replies:
    2
    Views:
    1,444
    Tommy
    Feb 13, 2004
  3. jlopes151
    Replies:
    2
    Views:
    617
    Steve C. Orr [MVP, MCSD]
    Mar 14, 2005
  4. =?Utf-8?B?ZGF2aWQ=?=

    embedded windows forms into web forms for control

    =?Utf-8?B?ZGF2aWQ=?=, Apr 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    5,206
    =?Utf-8?B?ZGF2aWQ=?=
    Apr 10, 2005
  5. Eric
    Replies:
    2
    Views:
    479
Loading...

Share This Page