Cannot Alert

H

hon123456

Dear all,

I have the following code which add a new record to
database, after the record has been added. I want to prompt a message
"Hello". But the following script does not promt.
Response.Write("<script>")
Response.Write("alert (""Hello"");")
response.write("</script>")

It just goto Response.redirect "OS_addnew.asp"

The following is my complete code:

if strshipper<>"" and strorigin<>"" and strdest<>"" and
strinvoice_no<>"" and strpo_no<>"" then



'**************************************************************************
' Insert Data
'**************************************************************************
Set objConn1 = Server.CreateObject("ADODB.Connection")
objConn1.Open "driver={SQL
Server};server=10.129.2.20;database=FIH;uid=sa;pwd=sa"

strSQL = "INSERT Oversea
(os_no,forwarder,station,service_level,shipper,consignee,origin,dest,incoterms,invoice_no,po_no,goods_desc,bu,qty,plt,ctn,loose_ctn,gw_hawb,cw_hawb,"
&_

"gw_pl,cw_pl,shpt_value,booking_receiving_date,booking_receiving_time,cargo_receiving_date,cargo_receiving_time,flight_no,flight_no1,flight_no2,flight_no3,"
&_

"etd_date,etd_time,etd_date1,etd_time1,etd_date2,etd_time2,etd_date3,etd_time3,eta_date,eta_time,eta_date1,eta_time1,eta_date2,eta_time2,eta_date3,eta_time3,"
&_

"hawb,mawb,mawb1,mawb2,mawb3,completed_date,completed_time,available_pu_date,available_pu_time,pod_date,pod_time,receiving_wh,event_report,inbound_no,outbound_no,remark,forwarder_pickup)"
&_
" values ('" & newdatecode &"','" & strforwarder &"','" &
strstation &"','" & strservice_level &"','" & strshipper &"','" &
strconsignee &"','" & strorigin &"','" & strdest &"', '" &
strincoterms &"','" & strinvoice_no &"','" & strpo_no &"','" &
strgoods_desc &"','" & strbu &"','" & strqty &"','" & strplt &"','" &
strctn &"','" & strloose_ctn &"','" & strgw_hawb &"','" & strcw_hawb
&"'," &_
"'" & strgw_pl &"','" & strcw_pl &"','" & strshpt_value &"'," &
strbooking_receiving_date &"," & strbooking_receiving_time &"," &
strcargo_receiving_date &"," & strcargo_receiving_time &",'" &
strflight_no &"','" & strflight_no1 &"','" & strflight_no2 &"','" &
strflight_no3 &"'," &_
"" & stretd_date &"," & stretd_time &"," & stretd_date1 &"," &
stretd_time1 &"," & stretd_date2 &"," & stretd_time2 &"," &
stretd_date3 &"," & stretd_time3 &"," & streta_date &"," & streta_time
&"," & streta_date1 &"," & streta_time1 &"," & streta_date2 &"," &
streta_time2 &"," & streta_date3 &"," & streta_time3 &"," &_
"'" & strhawb &"','" & strmawb &"','" & strmawb1 &"','" &
strmawb2 &"','" & strmawb3 &"'," & strcompleted_date &"," &
strcompleted_time &","& stravailable_pu_date &"," &
stravailable_pu_time &","& strPOD_date &"," & strPOD_time &",'" &
strreceiving_wh &"','" & strevent_report &"','" & strinbound_no &"','"
& stroutbound_no &"','" & strremark & "','" & strforwarder_pickup &
"')"

objConn1.Execute strSQL

Response.Write("<script>")
Response.Write("alert (""Hello"");")
response.write("</script>")

Response.redirect "OS_addnew.asp"

end if

Please Help. Thanks.
 
E

Evertjan.

hon123456 wrote on 26 mei 2008 in microsoft.public.inetserver.asp.general:
Dear all,

I have the following code which add a new record to
database, after the record has been added. I want to prompt a message
"Hello". But the following script does not promt.
Response.Write("<script>")
Response.Write("alert (""Hello"");")
response.write("</script>")

It just goto Response.redirect "OS_addnew.asp"

Response.redirect adds a header directive, so no page content is ever
transmitted to the client, so no clientside code can be executed.

Try:

%>
<script type='text/javascript'>
alert ('Hello');
location.href = 'OS_addnew.asp';
</script>
<%
 
D

daddywhite

Javascript is Client Side code and therefore is executed AFTER the
server side code, by which time you have "response.redirect" ed away!
So the javascript alert box never gets executed.

I would either:

1) Use a confirm box in javascript rather than alert and then the
confirm can handle the redirect
2) Display the confirmation response in the browser and have a
javascript timer which will redirect the user after 5 seconds for
example.
 
H

hon123456

Javascript is Client Side code and therefore is executed AFTER the
server side code, by which time you have "response.redirect" ed away!
So the javascript alert box never gets executed.

I would either:

1) Use a confirm box in javascript rather than alert and then the
confirm can handle the redirect
2) Display the confirmation response in the browser and have a
javascript timer which will redirect the user after 5 seconds for
example.

Thanks all,

But I am rather new to javascript , can u post some code
of solution

Thanks.
 
D

Dave Anderson

hon123456 said:
But I am rather new to javascript , can u post some code
of solution

No Javascript is needed:

<h1>Hello</h1>
<a href="OS_addnew.asp">Click here to continue</a>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top