Alerts in pop-up

12 posts by 3 authors in: Forums > CMS Builder
Last Post: June 18, 2011   (RSS)

By Toledoh - June 9, 2011

Hi all.

There's a number of instances where we have the generic code;
<?php if (@$errorsAndAlerts): ?>
<div style="color: #C00; font-weight: bold; font-size: 14px; font-family: arial;"><br/>
<?php echo $errorsAndAlerts; ?><br/>
</div>
<?php endif ?>


I was wondering if there's a way of having all these pop-up rather than be embedded within the page?
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Alerts in pop-up

By robin - June 10, 2011

Hey Tim,

Something like this might work for you:


<?php if (@$errorsAndAlerts): ?>
<script language="javascript" type="text/javascript">
alert('<?php echo $errorsAndAlerts; ?>');
</script>
<?php endif ?>


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Alerts in pop-up

By Toledoh - June 10, 2011

No, it's not happenning;

If you just click the subscribe button here http://182.160.128.132/~hannahdi/team.php with no data, the error appears under the form, but not as a pop-up.

I've place both the original alert code, and the new one to check.

Any suggestions?

<div id="newsletter">
<?php if ($showSignupForm): ?>
<form method="post" action="?">
<input type="hidden" name="save" value="1" />
<input type="text" name="email" value="<?php echo htmlspecialchars(@$_REQUEST['email']); ?>" class="newsField" />
<input class="newsButton" type="submit" name="submit" value="Go" />
</form>
<?php endif ?>
<p><a href="subscribers.php">Want more information?</a></p>
<?php if (@$errorsAndAlerts): ?>
<div style="color: #C00; font-weight: bold; font-size: 14px; font-family: arial;"><br/>
<?php echo $errorsAndAlerts; ?><br/>
</div>
<?php endif ?>
<?php if (@$errorsAndAlerts): ?>
<script language="javascript" type="text/javascript">
alert('<?php echo $errorsAndAlerts; ?>');
</script>
<?php endif ?>
</div>

Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Alerts in pop-up

By Jason - June 13, 2011

Hi Tim,

There seems to be an error with the javascript. Try this:

<?php if (@$errorsAndAlerts): ?>
<script language="javascript" type="text/javascript">
alert("<?php echo nl2br($errorsAndAlerts); ?>");
</script>
<?php endif ?>


This will also change any new line characters in your message into HTML <br> tags.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Alerts in pop-up

By Toledoh - June 13, 2011

Sorry Jason,

no go with that one either.
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] Alerts in pop-up

By Jason - June 13, 2011

Hi Tim,

You get an "unterminated literal" javascript error. When you're giving a value to $errorsAndReports, try not includinng any line break characters.

If that doesn't work, could you attach your .php file so I can take a closer look.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Alerts in pop-up

By Toledoh - June 13, 2011

Hi Jason,

I've done that, but still no go.

Have a look at the attached, which is included on every page - such as http://182.160.128.132/~hannahdi/index.php (Maybe the fact that there are 2 forms on team.php may be causing an issue?)
Cheers,

Tim (toledoh.com.au)
Attachments:

_insertrightcolumn.php 2K

Re: [Toledoh] Alerts in pop-up

By Jason - June 14, 2011

Hi Tim,

If you view the HTML Source of your page, you'll see that there is a line break inside the $errorAndAlerts message. I believe this is what's causing your javascript error.

So, for example, instead of assigning a value to $errorsAndAlerts like this:

$errorsAndAlerts .= "You must enter your email address!<br/>\n";

You could try this:

$errorsAndAlerts .= "You must enter your email address!";

Give that a try.
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Alerts in pop-up

By Toledoh - June 14, 2011

That's it Jason - works perfectly now.
Cheers,

Tim (toledoh.com.au)

Re: [Jason] Alerts in pop-up

By Toledoh - June 17, 2011

Hi Jason.

This is working, but I now get the pop-up alert, press OK, and then the message "Prevent this page from creating additional dfialogues" appears with a tick box.

Can you suggest what I should do to not have this?

Screen grab attached.
Cheers,

Tim (toledoh.com.au)
Attachments:

screen.jpg 209K