Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts

    Quick Clever Repeating Script

    Hi guys. Just after a quick php script that'll check the content of my page and change the url of a button depending upon whether an image or text appears more than once.

    e.g. If the image "roomicon.gif" appears more than once on the page "basket.php" i would like the submit link to goto "/thanks2.php" otherwise to go to "thanks.php"

    Any ideas on how to achieve this??

  • #2
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    PHP Code:
    <?php
    ob_start
    ();
    ?>

    HTML code here

    roomicon.gif

    roomicon.gif

    <form action="[action]" method="post">
    <input type="submit" name="submit" value="submit">
    </form>

    <?php
    $contents 
    ob_get_clean();
    if (
    substr_count($contents'roomicon.gif') > 1) {$action 'thanks2.php';} else {$action 'thanks.php';}
    $contents str_replace('[action]'$action$contents);
    echo 
    $contents;
    exit();
    ?>

  • Users who have thanked devinemke for this post:

    thoford75 (10-14-2009)

  • #3
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts
    My code is currently:

    echo '<a href="/thanks2.php"><span id="complete-order-button"><!--[if LTE IE 7]><a href="/thanks.php"><![endif]--><img src="/images/capital-go-button.png" alt="Sumbit" /><!--[if IE 6]></a><![endif]-->Submit</span></a>';

    Would I still be able to use [action] in this scenario?

  • #4
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts
    Also, on this topic, if the value of text is more than "20m2" I want the submit button to go to thanks3.php.

    Can this be done alongside the image lookup?

  • #5
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts
    Update. I have managed to get the image lookup working now

    Would i have to create another ob_start(); code with regards to looking for text above a certain number (20m2)? And how would this work alongside the current lookup?

  • #6
    Regular Coder
    Join Date
    Jan 2007
    Posts
    154
    Thanks
    52
    Thanked 0 Times in 0 Posts
    New question!

    How can I use this script it relation to radio buttons. I have three buttons:
    Code:
    <label>
    	  <input name="radiobutton" id="wholehouse" type="radio" value="radiobutton" />
    	  Whole House</label>
    	  <label>
    	  <input name="radiobutton" id="multiplerooms" type="radio" value="radiobutton" />
    	  Multiple Rooms</label>
    	  <label>
    	  <input name="radiobutton" id="oneroom" type="radio" value="radiobutton" />
    	  One Room</label>
    I want the [action] link to change depending upon which radio button is selected

    Thanks


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •