Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2007
    Posts
    178
    Plugin Contributions
    0

    Default Display a jQuery Alert

    I have a custom page to run a search. If the search fails, I would like an Alert box to popup informing the user.
    On my custom search page, I have it set a $_SESSION variable with the appropriate error message.
    I am trying to write some code on the tbl_main_page.php page to display my message.

    I've tried something like this:
    Code:
    <?php
    //CHECK FOR ERROR AND DISPLAY IT
    if(isset($_SESSION['badsearch'])) {
    	$errormsg = $_SESSION['badsearch'];
    	echo "<script>alert(\"$errormsg\"); </script>";	
    	unset($_SESSION['badsearch']);
    }
    ?>
    but, nothing shows up.

    Anyone have any ideas how I can make this work?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,378
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Display a jQuery Alert

    I'd start by merely echoing out the badsearch message from the session variable, and be sure that it actually contains a message.
    And then I'd check the raw HTML ("view source" in the browser, and/or use Firebug etc) to see whether the <script> is output at all.

    I hope the following comment doesn't come across as offensive. It isn't meant to be:
    I'm not sure what this has to do with jQuery. I don't see anything to do with jQuery in your code or the concept you're describing. Either I'm missing something from your post or perhaps you're using the term "jQuery" to refer also to generic javascript (a simple "alert()" call is just javascript, not specific to jQuery).
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Sep 2007
    Posts
    178
    Plugin Contributions
    0

    Default Re: Display a jQuery Alert

    Quote Originally Posted by DrByte View Post
    I hope the following comment doesn't come across as offensive. It isn't meant to be:
    I'm not sure what this has to do with jQuery. I don't see anything to do with jQuery in your code or the concept you're describing. Either I'm missing something from your post or perhaps you're using the term "jQuery" to refer also to generic javascript (a simple "alert()" call is just javascript, not specific to jQuery).
    Thanks for the help.
    Yes, I mistakenly used "jQuery" to refer to generic JavaScript.

  4. #4
    Join Date
    Sep 2007
    Posts
    178
    Plugin Contributions
    0

    Default Re: Display a jQuery Alert

    Are $_SESSION variables allowed on custom pages?
    I have set session_start() at the top of my custom page.

    To test, I set $_SESSION['badsearch'] = "Testing"; on my custom page, which is /shop/product.php.
    In the common tpl_header.php, I attempt to echo $_SESSION['badsearch'], but nothing shows up.

 

 

Similar Threads

  1. v150 Admin Password Change Alert Message Display -- Support Thread
    By lat9 in forum All Other Contributions/Addons
    Replies: 13
    Last Post: 24 Dec 2015, 04:53 PM
  2. v139h Jquery
    By AmyS in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 23 Sep 2012, 09:21 PM
  3. Jquery?
    By cpdantha in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 16 Feb 2011, 04:04 PM
  4. A jQuery question
    By damiantaylor in forum General Questions
    Replies: 5
    Last Post: 8 May 2010, 08:57 PM
  5. JQuery + ZenCart
    By j4ckripp3r in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 17 Apr 2009, 06:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR