Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/52947-using-an-img-src-in-php/
Share on other sites

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>

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>

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.