Jump to content


Photo

submit button image


Best Answer yandoo, 25 June 2013 - 12:06 PM

Thank you for your reply but i tried that too and it still didn't work either. 

 

Here's how I just fixed it:

 

css

.button {
background:url(style/add_to_cart.jpg);
width:90px;
height:25px;
border:0px;
} 
'<input type="submit" value="" name="button" id="button" class="button" />';

Thank you for your replies and input. 

 

:)

Go to the full post


  • Please log in to reply
5 replies to this topic

#1 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 25 June 2013 - 08:09 AM

Hiya just a quickie, 

 

I'm using php and trying to echo out a form. It works just fine but when I try and replace the submit button with an image, although the functionality of the form is working the image doesn't appear??? there's just a border around an empty image. 

 

 

This was what it was originally

<input type="submit" name="button" id="button" value="Add to Cart" />

And this is what I tried to change it to.

<input type="image" id="button" src"style/add_to_cart.jpg" alt="Add to Cart" />

Any ideas?? Could it be that I using php to echo out this form?

 

Thanks



#2 denno020

denno020

    Advanced Member

  • Members
  • PipPipPip
  • 712 posts
  • LocationAustralia

Posted 25 June 2013 - 08:28 AM

This is how you could do it, a quick and dirty way:

 

<input type="submit" name="submit" id="submit" style="background-image:url('path_to_image/add_to_cart.jpg')"/>

 

If you do it that way, then you'd probably also want to set the width and height of the button to match that of the dimensions of the image you're using, otherwise it won't display correctly.

 

Denno



#3 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 25 June 2013 - 10:28 AM

Thanks for your reply Denno. I've had to use more double quotes or `` sloped quotes rather than singles for the url path because the whole form is echoed in php. Doing it this way it doesn't work instead of the image the traditional submit button appears.

 

Is there a way to get not being able to use the single quotes? 

 

Thank you

<input type="submit" name="submit" id="submit" style="background-image:url("path_to_image/add_to_cart.jpg")"/>


<input type="submit" name="submit" id="submit" style="background-image:url(`path_to_image/add_to_cart.jpg`)"/>


#4 Psycho

Psycho

    Advanced Member

  • Gurus
  • 10,746 posts
  • LocationCanada

Posted 25 June 2013 - 11:10 AM

And this is what I tried to change it to.

<input type="image" id="button" src"style/add_to_cart.jpg" alt="Add to Cart" />

Any ideas?? Could it be that I using php to echo out this form?

 

Look closer at your "src" parameter - something is missing.

 

 

 

Thanks for your reply Denno. I've had to use more double quotes or `` sloped quotes rather than singles for the url path because the whole form is echoed in php. Doing it this way it doesn't work instead of the image the traditional submit button appears.

 

Is there a way to get not being able to use the single quotes? 

 

Thank you

<input type="submit" name="submit" id="submit" style="background-image:url("path_to_image/add_to_cart.jpg")"/>


<input type="submit" name="submit" id="submit" style="background-image:url(`path_to_image/add_to_cart.jpg`)"/>

 

You need to learn how to work with either type of quote in any context. It shouldn't matter if the output is done inside or outside of an echo statement. I assume you are echoing the string within an echo that is defined using single quotes. There are multiple options to do what you were trying above (even though you can stick with your first attempt after correcting the src parameter). Here is one solution

//Escape the single quotes inside the string
echo '<input type="submit" name="submit" id="submit" style="background-image:url(\'path_to_image/add_to_cart.jpg\')"/>';

The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

#5 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 25 June 2013 - 12:06 PM   Best Answer

Thank you for your reply but i tried that too and it still didn't work either. 

 

Here's how I just fixed it:

 

css

.button {
background:url(style/add_to_cart.jpg);
width:90px;
height:25px;
border:0px;
} 
'<input type="submit" value="" name="button" id="button" class="button" />';

Thank you for your replies and input. 

 

:)



#6 yandoo

yandoo

    Advanced Member

  • Members
  • PipPipPip
  • 470 posts

Posted 25 June 2013 - 12:08 PM

I found that without putting the value="" the word submit appeared on the image. 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com