PDA

View Full Version : Some Doubt about Javascript.


victoria_1018
10-29-2002, 06:56 AM
Hi,
I am doing asp programming and had used some javascripts to enhance my program.

There is this function I shall like to have it added to my program but I don't know if it will work.

I shall like to do an alert using javascript, where this alert script will pull information from the database, and prompt the user there are new records found where status equal to "Not Approved".

This alert script will pop up every time the user login to that page, provided records found, otherwise, alert message will not pop up.

If this cannot be done by Javascript, what other methods can I use to make mt request work?

Thanks

Regards
Victoria

glenngv
10-29-2002, 07:04 AM
you can insert server-side codes in between javascript codes just as in HTML tags.

<script language="javascript">
var msg = "<%=strMessage%>";
if (msg!="") alert(msg);
</script>

victoria_1018
10-29-2002, 07:11 AM
Dear glenngv,

Can I write a select statement inside the javascript?
And Can I replace the strMessage with Response.Write?

Thanks
Regards
Victoria

glenngv
10-29-2002, 08:01 AM
<%
'code here that retrieves data from db
if not rs.eof then strMessage = "New Records found."
%>

<script language="javascript">
var msg = "<%=strMessage%>";
if (msg!="") alert(msg);
</script>

is the same as:

<script language="javascript">
<%
'code here that retrieves data from db
if not rs.eof then strMessage = "New Records found."
%>
var msg = "<%response.write strMessage%>";
if (msg!="") alert(msg);
</script>

remember, asp codes are executed on the server-side from top to bottom, and just generates html and javascript codes which will be run by the browser on the client-side.
I advice you to know the difference between server-side and client-side. I think whammy can provide you some links.

victoria_1018
10-29-2002, 08:04 AM
Thanks Glenn,
I will read that up.

Regards
Victoria