Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > VB code is too fast => gives wrong value

Reply
Thread Tools

VB code is too fast => gives wrong value

 
 
Andre
Guest
Posts: n/a
 
      06-29-2004
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é


 
Reply With Quote
 
 
 
 
Mark Schupp
Guest
Posts: n/a
 
      06-29-2004
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
www.ielearning.com


"Andre" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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é
>
>



 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      06-29-2004
> MsgBox "=<%=totd%>"

Or

MsgBox "<%=totd%>"

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


 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      06-29-2004
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" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> 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é
>
>



 
Reply With Quote
 
Andre
Guest
Posts: n/a
 
      06-29-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> a écrit dans le message de
> news:(E-Mail Removed)...
> > 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é
> >
> >

>
>



 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      06-29-2004
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
www.ielearning.com


"Andre" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> a écrit dans le message de
> > news:(E-Mail Removed)...
> > > 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é
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      06-30-2004
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" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> a écrit dans le message de
> > news:(E-Mail Removed)...
> > > 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é
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Casting double by long gives wrong value. johnny boy C Programming 16 11-30-2009 08:07 AM
WiMAX in 2010: Too little, too late? How fast, how far, how much? Obaid MCSA 0 10-19-2009 12:12 PM
WiMAX in 2010: Too little, too late? How fast, how far, how much? Obaid MCAD 0 10-19-2009 12:12 PM
TkPhotoImage.copy always gives "too many colors" Error C. Dagnon Ruby 6 05-19-2009 03:35 PM
Firefox gives up too soon Gualtier Malde Firefox 10 04-18-2006 05:11 AM



Advertisments