Current location: Hot Scripts Forums » General Web Coding » JavaScript » Alert Box


Alert Box

Reply
  #1 (permalink)  
Old 05-24-07, 05:01 AM
alane alane is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 71
Thanks: 6
Thanked 0 Times in 0 Posts
Alert Box

Hi
I have a web site based on php to display tables of servicing manuals which works ok. I now want to add an alert box that displays if there is a product the subject of a 'Recall' or 'Safety' notice.

If I add the following to the display page I get the alert box appear exactly as wanted:

Code:
<script type="text/javascript">
{
alert("One or more models listed in this table are the subject of a Recall/Safety Alert")
}
</script>
However I obviously only want this to display when a php variable '$safety_alert' is set to true. (I can set this in the php section to anything that is no problem) but how do I get the value of a this, or any other, php variable to control a javascript function such as this one please?

Thanks
Reply With Quote
  #2 (permalink)  
Old 05-24-07, 05:15 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Like this?

PHP Code:

<?php

if ($safety_alert)
{
?>
    <script type="text/javascript">
    {
        alert("One or more models listed in this table are the subject of a Recall/Safety Alert")
    }
    </script>
<?php
}
?>
Reply With Quote
  #3 (permalink)  
Old 05-24-07, 07:55 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
You could also do it like this:

PHP Code:

 <?php
if($safety_alert){echo "<script type='text/javascript'>alert('One or more models listed in this table are the subject of a Recall/Safety Alert')</script>";}
?>
__________________
Jerry Broughton

Last edited by job0107; 05-24-07 at 07:58 AM.
Reply With Quote
  #4 (permalink)  
Old 05-24-07, 01:11 PM
alane alane is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 71
Thanks: 6
Thanked 0 Times in 0 Posts
Again I am indebited to this forum.

I spent ages trying to work out how to include the javascript into php!

Thanks for the replies works a treat.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript floating box? Hunter JavaScript 4 08-02-06 10:50 AM
Delete confirmation box Programme JavaScript 1 08-08-05 03:56 AM
Forms help input box switch to Select box dstran JavaScript 1 04-19-05 12:17 AM
change drop down box based on textbox talax JavaScript 1 02-24-05 07:38 AM
Shout box, comment box, or search script. Need help to find all! Spreegem Script Requests 1 05-29-04 09:45 PM


All times are GMT -5. The time now is 11:26 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.