...

View Full Version : Quick Clever Repeating Script



thoford75
10-14-2009, 08:43 PM
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??

devinemke
10-14-2009, 09:09 PM
<?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();
?>

thoford75
10-14-2009, 09:29 PM
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?

thoford75
10-14-2009, 09:36 PM
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?

thoford75
10-15-2009, 12:33 PM
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?

thoford75
10-22-2009, 06:15 PM
New question!

How can I use this script it relation to radio buttons. I have three buttons:


<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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum