AikenDrum Posted May 25, 2007 Share Posted May 25, 2007 Hi guys - I know that someone here can help me :-) I need to use an image as a submit button - this image is the result of a php if statement - my current code is below - I need to swap out the value="x" for the result of the php if - any ideas guys ? AikenD <form id="Assign_<?php echo $Contact ?>" action="Assign.php" method="post"> <input type="hidden" name="search" value="<?php echo $search; ?>"> <td> <?php if($selected == 'X') { ?> <img src="images/checked.gif"> <?php }else{ ?> <img src="images/unchecked.gif"> <?php } ?> </td> <td> <input type ="submit" name="assign" value="x"> </td> </form> Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/ Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 the result ? results of what ? try {$_POST['search']} <?php echo '<td> <input type ="submit" name="assign" value="'.$_POST['search'].'">'; ?> EDIT: whole thing being <form id="Assign_<?php echo $Contact ?>" action="Assign.php" method="post"> <input type="hidden" name="search" value="<?php echo $search; ?>"> <td> <?php if($selected == 'X') { ?> <img src="images/checked.gif"> <?php }else{ ?> <img src="images/unchecked.gif"> <?php } ?> </td> <?php echo '<td> <input type ="submit" name="assign" value="'.$_POST['search'].'">'; ?> </td> </form> Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/#findComment-261465 Share on other sites More sharing options...
AikenDrum Posted May 25, 2007 Author Share Posted May 25, 2007 The result of the if statement ! if($selected == 'X') { ?> <img src="images/checked.gif"> <?php }else{ ?> <img src="images/unchecked.gif"> <?php } ?> AikenD Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/#findComment-261468 Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 the result would be true or false.. which makes no sense! unless you wish to set the value of assign to true or false! maybe you should re-think the question try this how to ask questions - the smart way Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/#findComment-261475 Share on other sites More sharing options...
AndyB Posted May 25, 2007 Share Posted May 25, 2007 I suspect the question is 'depending on the value of $selected, how can I use a different image as the "submit" in my form?' There ya go MadTechie. Try that one Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/#findComment-261479 Share on other sites More sharing options...
jitesh Posted May 25, 2007 Share Posted May 25, 2007 <input type="image" src="image/button.jpg" name="submit" /> Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/#findComment-261482 Share on other sites More sharing options...
MadTechie Posted May 25, 2007 Share Posted May 25, 2007 I suspect the question is 'depending on the value of $selected, how can I use a different image as the "submit" in my form?' There ya go MadTechie. Try that one Cheers Andy in which case i would probably do this <form id="Assign_<?php echo $Contact ?>" action="Assign.php" method="post"> <input type="hidden" name="search" value="<?php echo $search; ?>"> <td> <?php if($selected == 'X') { $image = "images/checked.gif"; }else{ $image = "images/unchecked.gif"; } echo "<img src='$image'>"; ?> </td> <td> <input type ="image" name="assign" src="<?php echo $image;?>"> </td> </form> Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/#findComment-261487 Share on other sites More sharing options...
AikenDrum Posted May 25, 2007 Author Share Posted May 25, 2007 I suspect the question is 'depending on the value of $selected, how can I use a different image as the "submit" in my form?' There ya go MadTechie. Try that one Cheers Andy in which case i would probably do this <form id="Assign_<?php echo $Contact ?>" action="Assign.php" method="post"> <input type="hidden" name="search" value="<?php echo $search; ?>"> <td> <?php if($selected == 'X') { $image = "images/checked.gif"; }else{ $image = "images/unchecked.gif"; } echo "<img src='$image'>"; ?> </td> <td> <input type ="image" name="assign" src="<?php echo $image;?>"> </td> </form> Exactly - many thanks, but worked it out myself in last 10 minutes - still valuable lesson in learning how to ask a question Cheers guys AikenD Quote Link to comment https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/#findComment-261493 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.