VB code is too fast => gives wrong value

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default VB code is too fast => gives wrong value

    Hi,

    I need to fetch a value in an Access db, so i use a form to pass the
    parameter for the SQL statement fromVB client to ASP. After the submit line
    in VBscript, i expect the value in order to test it and go further in
    VBscript. But my problem is when clicking on the button, that the VB code
    doesn't wait to get that value and continues directly, so the a=<%=totd%>
    line give 0 in stead of the real value. If i click a second time, i get the
    value.
    Any way to let de VB code after dtot.submit wait before it gets the value?
    See the code:
    <%
    totd = 0
    dat=Request.Form("dt")
    If Request.Form("dt") <> "" Then totd = records()
    Function records()
    set objdc = Server.CreateObject("ADODB.Connection")
    objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
    =d:\access\newres.mdb")
    sql="select logon, count(uur) as totdag from studres where cdate(dag)='" &
    dat & "' "
    set rs=Server.CreateObject("ADODB.recordset")
    rs.open sql, objdc, 3, 3
    records=rs.recordcount
    Set rs = Nothing
    End Function
    %>
    <html><head><title>Nieuwe pagina 1</title></head><body>
    <script language=vbscript>
    sub hfd_onclick()
    a=0
    dat="6/30/2004"
    document.getElementById("dt").value=dat
    dtot.action="test3.asp" '=name of this file
    dtot.method="post"
    dtot.submit
    'too fast here
    a=<%=totd%> '=0 on the first click, the real value on the second
    click
    msgbox a
    end sub
    </script>
    <form name=dtot>
    <input name="dt" type="hidden" value="" >
    <INPUT name=hfd TYPE="button">
    </form>

    Thanks
    andré


    Andre Guest

  2. Similar Questions and Discussions

    1. what is wrong in this code
      this is the code: #! Perl\bin\perl use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get( $url );
    2. what's wrong with my code ?
      Hi guys. I have follow C# code in my WebService. --------------------------------------- WebMethod (Description="Return current stock price")]...
    3. Skiping Frame Code on Fast Computers
      We are experiencing problems with a Flash app that has worked for 3 years: users with very new, fast P4 computers, Win XP, and Flash players 6 and...
    4. Something Wrong with the code?
      I put this Perl program together. The idea is to be able to submit a path and then program will delete contents of that file in the path. ...
    5. What's wrong in this code?
      I wrote a simple file transfer, but it doesn't work! When I try to open the transferred file it says: "The end of file cropped" or "the file header...
  3. #2

    Default Re: VB code is too fast => gives wrong value

    a=<%=totd%>

    is in the client-side vbscript so it will already be executed (and a set to
    0) before you submit the form. If you need an alert box to display a result
    of the form post you will have to put it outside of the onsubmit function

    Try

    MsgBox "=<%=totd%>"

    after the "End Sub" statement in your client-side script block

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    [url]www.ielearning.com[/url]


    "Andre" <aa@no.it> wrote in message
    news:OK2SCgeXEHA.3112@tk2msftngp13.phx.gbl...
    > Hi,
    >
    > I need to fetch a value in an Access db, so i use a form to pass the
    > parameter for the SQL statement fromVB client to ASP. After the submit
    line
    > in VBscript, i expect the value in order to test it and go further in
    > VBscript. But my problem is when clicking on the button, that the VB code
    > doesn't wait to get that value and continues directly, so the a=<%=totd%>
    > line give 0 in stead of the real value. If i click a second time, i get
    the
    > value.
    > Any way to let de VB code after dtot.submit wait before it gets the value?
    > See the code:
    > <%
    > totd = 0
    > dat=Request.Form("dt")
    > If Request.Form("dt") <> "" Then totd = records()
    > Function records()
    > set objdc = Server.CreateObject("ADODB.Connection")
    > objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
    > =d:\access\newres.mdb")
    > sql="select logon, count(uur) as totdag from studres where cdate(dag)='" &
    > dat & "' "
    > set rs=Server.CreateObject("ADODB.recordset")
    > rs.open sql, objdc, 3, 3
    > records=rs.recordcount
    > Set rs = Nothing
    > End Function
    > %>
    > <html><head><title>Nieuwe pagina 1</title></head><body>
    > <script language=vbscript>
    > sub hfd_onclick()
    > a=0
    > dat="6/30/2004"
    > document.getElementById("dt").value=dat
    > dtot.action="test3.asp" '=name of this file
    > dtot.method="post"
    > dtot.submit
    > 'too fast here
    > a=<%=totd%> '=0 on the first click, the real value on the
    second
    > click
    > msgbox a
    > end sub
    > </script>
    > <form name=dtot>
    > <input name="dt" type="hidden" value="" >
    > <INPUT name=hfd TYPE="button">
    > </form>
    >
    > Thanks
    > andré
    >
    >

    Mark Schupp Guest

  4. #3

    Default Re: VB code is too fast => gives wrong value

    > MsgBox "=<%=totd%>"

    Or

    MsgBox "<%=totd%>"

    --
    [url]http://www.aspfaq.com/[/url]
    (Reverse address to reply.)


    Aaron [SQL Server MVP] Guest

  5. #4

    Default Re: VB code is too fast => gives wrong value

    It looks like you expect the change to take place immediately after calling
    the submit method. Display the HTML source for your page. It's likely you'll
    see :

    dtot.submit
    a=0
    MsgBox a

    So :
    - the page is "submitted" (actually it's more likely "queued" as the script
    must terminate before the page is really submitted)
    - a is 0
    - 0 is displayed

    The script ends, the page is submitted and you get the new updated client
    side code...

    Patrice

    --

    "Andre" <aa@no.it> a écrit dans le message de
    news:OK2SCgeXEHA.3112@tk2msftngp13.phx.gbl...
    > Hi,
    >
    > I need to fetch a value in an Access db, so i use a form to pass the
    > parameter for the SQL statement fromVB client to ASP. After the submit
    line
    > in VBscript, i expect the value in order to test it and go further in
    > VBscript. But my problem is when clicking on the button, that the VB code
    > doesn't wait to get that value and continues directly, so the a=<%=totd%>
    > line give 0 in stead of the real value. If i click a second time, i get
    the
    > value.
    > Any way to let de VB code after dtot.submit wait before it gets the value?
    > See the code:
    > <%
    > totd = 0
    > dat=Request.Form("dt")
    > If Request.Form("dt") <> "" Then totd = records()
    > Function records()
    > set objdc = Server.CreateObject("ADODB.Connection")
    > objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
    > =d:\access\newres.mdb")
    > sql="select logon, count(uur) as totdag from studres where cdate(dag)='" &
    > dat & "' "
    > set rs=Server.CreateObject("ADODB.recordset")
    > rs.open sql, objdc, 3, 3
    > records=rs.recordcount
    > Set rs = Nothing
    > End Function
    > %>
    > <html><head><title>Nieuwe pagina 1</title></head><body>
    > <script language=vbscript>
    > sub hfd_onclick()
    > a=0
    > dat="6/30/2004"
    > document.getElementById("dt").value=dat
    > dtot.action="test3.asp" '=name of this file
    > dtot.method="post"
    > dtot.submit
    > 'too fast here
    > a=<%=totd%> '=0 on the first click, the real value on the
    second
    > click
    > msgbox a
    > end sub
    > </script>
    > <form name=dtot>
    > <input name="dt" type="hidden" value="" >
    > <INPUT name=hfd TYPE="button">
    > </form>
    >
    > Thanks
    > andré
    >
    >

    Patrice Guest

  6. #5

    Default Re: VB code is too fast => gives wrong value

    Thanks, but in fact, i need that value from ASP in the procedure
    hfd_onclick() because that value must be tested further in that procedure. I
    put msgbox just to check the value. For example, if the value = 2, then
    button "A" in the page must become visible, otherwise button "B" etc ...

    "Patrice" <nobody@nowhere.com> wrote in message
    news:eMb0vyeXEHA.3016@tk2msftngp13.phx.gbl...
    > It looks like you expect the change to take place immediately after
    calling
    > the submit method. Display the HTML source for your page. It's likely
    you'll
    > see :
    >
    > dtot.submit
    > a=0
    > MsgBox a
    >
    > So :
    > - the page is "submitted" (actually it's more likely "queued" as the
    script
    > must terminate before the page is really submitted)
    > - a is 0
    > - 0 is displayed
    >
    > The script ends, the page is submitted and you get the new updated client
    > side code...
    >
    > Patrice
    >
    > --
    >
    > "Andre" <aa@no.it> a écrit dans le message de
    > news:OK2SCgeXEHA.3112@tk2msftngp13.phx.gbl...
    > > Hi,
    > >
    > > I need to fetch a value in an Access db, so i use a form to pass the
    > > parameter for the SQL statement fromVB client to ASP. After the submit
    > line
    > > in VBscript, i expect the value in order to test it and go further in
    > > VBscript. But my problem is when clicking on the button, that the VB
    code
    > > doesn't wait to get that value and continues directly, so the
    a=<%=totd%>
    > > line give 0 in stead of the real value. If i click a second time, i get
    > the
    > > value.
    > > Any way to let de VB code after dtot.submit wait before it gets the
    value?
    > > See the code:
    > > <%
    > > totd = 0
    > > dat=Request.Form("dt")
    > > If Request.Form("dt") <> "" Then totd = records()
    > > Function records()
    > > set objdc = Server.CreateObject("ADODB.Connection")
    > > objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
    > > =d:\access\newres.mdb")
    > > sql="select logon, count(uur) as totdag from studres where cdate(dag)='"
    &
    > > dat & "' "
    > > set rs=Server.CreateObject("ADODB.recordset")
    > > rs.open sql, objdc, 3, 3
    > > records=rs.recordcount
    > > Set rs = Nothing
    > > End Function
    > > %>
    > > <html><head><title>Nieuwe pagina 1</title></head><body>
    > > <script language=vbscript>
    > > sub hfd_onclick()
    > > a=0
    > > dat="6/30/2004"
    > > document.getElementById("dt").value=dat
    > > dtot.action="test3.asp" '=name of this file
    > > dtot.method="post"
    > > dtot.submit
    > > 'too fast here
    > > a=<%=totd%> '=0 on the first click, the real value on the
    > second
    > > click
    > > msgbox a
    > > end sub
    > > </script>
    > > <form name=dtot>
    > > <input name="dt" type="hidden" value="" >
    > > <INPUT name=hfd TYPE="button">
    > > </form>
    > >
    > > Thanks
    > > andré
    > >
    > >
    >
    >

    Andre Guest

  7. #6

    Default Re: VB code is too fast => gives wrong value

    That is not how http works. You will have to submit the form and then in the
    new page returned by that request to the server, add Javascript code to do
    whatever further processing you need.

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    [url]www.ielearning.com[/url]


    "Andre" <aa@no.it> wrote in message
    news:uhNKD9gXEHA.2844@TK2MSFTNGP12.phx.gbl...
    > Thanks, but in fact, i need that value from ASP in the procedure
    > hfd_onclick() because that value must be tested further in that procedure.
    I
    > put msgbox just to check the value. For example, if the value = 2, then
    > button "A" in the page must become visible, otherwise button "B" etc ...
    >
    > "Patrice" <nobody@nowhere.com> wrote in message
    > news:eMb0vyeXEHA.3016@tk2msftngp13.phx.gbl...
    > > It looks like you expect the change to take place immediately after
    > calling
    > > the submit method. Display the HTML source for your page. It's likely
    > you'll
    > > see :
    > >
    > > dtot.submit
    > > a=0
    > > MsgBox a
    > >
    > > So :
    > > - the page is "submitted" (actually it's more likely "queued" as the
    > script
    > > must terminate before the page is really submitted)
    > > - a is 0
    > > - 0 is displayed
    > >
    > > The script ends, the page is submitted and you get the new updated
    client
    > > side code...
    > >
    > > Patrice
    > >
    > > --
    > >
    > > "Andre" <aa@no.it> a écrit dans le message de
    > > news:OK2SCgeXEHA.3112@tk2msftngp13.phx.gbl...
    > > > Hi,
    > > >
    > > > I need to fetch a value in an Access db, so i use a form to pass the
    > > > parameter for the SQL statement fromVB client to ASP. After the submit
    > > line
    > > > in VBscript, i expect the value in order to test it and go further in
    > > > VBscript. But my problem is when clicking on the button, that the VB
    > code
    > > > doesn't wait to get that value and continues directly, so the
    > a=<%=totd%>
    > > > line give 0 in stead of the real value. If i click a second time, i
    get
    > > the
    > > > value.
    > > > Any way to let de VB code after dtot.submit wait before it gets the
    > value?
    > > > See the code:
    > > > <%
    > > > totd = 0
    > > > dat=Request.Form("dt")
    > > > If Request.Form("dt") <> "" Then totd = records()
    > > > Function records()
    > > > set objdc = Server.CreateObject("ADODB.Connection")
    > > > objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
    > > > =d:\access\newres.mdb")
    > > > sql="select logon, count(uur) as totdag from studres where
    cdate(dag)='"
    > &
    > > > dat & "' "
    > > > set rs=Server.CreateObject("ADODB.recordset")
    > > > rs.open sql, objdc, 3, 3
    > > > records=rs.recordcount
    > > > Set rs = Nothing
    > > > End Function
    > > > %>
    > > > <html><head><title>Nieuwe pagina 1</title></head><body>
    > > > <script language=vbscript>
    > > > sub hfd_onclick()
    > > > a=0
    > > > dat="6/30/2004"
    > > > document.getElementById("dt").value=dat
    > > > dtot.action="test3.asp" '=name of this file
    > > > dtot.method="post"
    > > > dtot.submit
    > > > 'too fast here
    > > > a=<%=totd%> '=0 on the first click, the real value on the
    > > second
    > > > click
    > > > msgbox a
    > > > end sub
    > > > </script>
    > > > <form name=dtot>
    > > > <input name="dt" type="hidden" value="" >
    > > > <INPUT name=hfd TYPE="button">
    > > > </form>
    > > >
    > > > Thanks
    > > > andré
    > > >
    > > >
    > >
    > >
    >
    >

    Mark Schupp Guest

  8. #7

    Default Re: VB code is too fast => gives wrong value

    Here you are mixing client and server side processing :

    - if you want to post the data, post them and have the server side page
    recreates the page with the appropriate buttons
    - if you don't need to post the data just have some client JavaScript code
    that updates the current page

    Keep in mind that the life cycle is always :
    - the browser ask a page (possibly posting data)
    - the server responds with a new page
    - the browser can then handle the page locally until another request is made
    to the server (possibly posting data)

    Patrice



    "Andre" <aa@no.it> a écrit dans le message de
    news:uhNKD9gXEHA.2844@TK2MSFTNGP12.phx.gbl...
    > Thanks, but in fact, i need that value from ASP in the procedure
    > hfd_onclick() because that value must be tested further in that procedure.
    I
    > put msgbox just to check the value. For example, if the value = 2, then
    > button "A" in the page must become visible, otherwise button "B" etc ...
    >
    > "Patrice" <nobody@nowhere.com> wrote in message
    > news:eMb0vyeXEHA.3016@tk2msftngp13.phx.gbl...
    > > It looks like you expect the change to take place immediately after
    > calling
    > > the submit method. Display the HTML source for your page. It's likely
    > you'll
    > > see :
    > >
    > > dtot.submit
    > > a=0
    > > MsgBox a
    > >
    > > So :
    > > - the page is "submitted" (actually it's more likely "queued" as the
    > script
    > > must terminate before the page is really submitted)
    > > - a is 0
    > > - 0 is displayed
    > >
    > > The script ends, the page is submitted and you get the new updated
    client
    > > side code...
    > >
    > > Patrice
    > >
    > > --
    > >
    > > "Andre" <aa@no.it> a écrit dans le message de
    > > news:OK2SCgeXEHA.3112@tk2msftngp13.phx.gbl...
    > > > Hi,
    > > >
    > > > I need to fetch a value in an Access db, so i use a form to pass the
    > > > parameter for the SQL statement fromVB client to ASP. After the submit
    > > line
    > > > in VBscript, i expect the value in order to test it and go further in
    > > > VBscript. But my problem is when clicking on the button, that the VB
    > code
    > > > doesn't wait to get that value and continues directly, so the
    > a=<%=totd%>
    > > > line give 0 in stead of the real value. If i click a second time, i
    get
    > > the
    > > > value.
    > > > Any way to let de VB code after dtot.submit wait before it gets the
    > value?
    > > > See the code:
    > > > <%
    > > > totd = 0
    > > > dat=Request.Form("dt")
    > > > If Request.Form("dt") <> "" Then totd = records()
    > > > Function records()
    > > > set objdc = Server.CreateObject("ADODB.Connection")
    > > > objdc.Open("provider=Microsoft.Jet.OLEDB.4.0; Data Source
    > > > =d:\access\newres.mdb")
    > > > sql="select logon, count(uur) as totdag from studres where
    cdate(dag)='"
    > &
    > > > dat & "' "
    > > > set rs=Server.CreateObject("ADODB.recordset")
    > > > rs.open sql, objdc, 3, 3
    > > > records=rs.recordcount
    > > > Set rs = Nothing
    > > > End Function
    > > > %>
    > > > <html><head><title>Nieuwe pagina 1</title></head><body>
    > > > <script language=vbscript>
    > > > sub hfd_onclick()
    > > > a=0
    > > > dat="6/30/2004"
    > > > document.getElementById("dt").value=dat
    > > > dtot.action="test3.asp" '=name of this file
    > > > dtot.method="post"
    > > > dtot.submit
    > > > 'too fast here
    > > > a=<%=totd%> '=0 on the first click, the real value on the
    > > second
    > > > click
    > > > msgbox a
    > > > end sub
    > > > </script>
    > > > <form name=dtot>
    > > > <input name="dt" type="hidden" value="" >
    > > > <INPUT name=hfd TYPE="button">
    > > > </form>
    > > >
    > > > Thanks
    > > > andré
    > > >
    > > >
    > >
    > >
    >
    >

    Patrice 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