Results 1 to 6 of 6

Thread: Inserting PHP into button

  1. #1
    Join Date
    Dec 2009
    Posts
    48

    Inserting PHP into button

    I am trying to make a website for my company i have a button and a PHP code. They are working smoothly if they are separate from each other but whenever i try to bind them together, They stop working so i am putting the code segments below

    HTML Code:
    <FORM METHOD="LINK" ACTION="../chkout/cart1/">
    <INPUT TYPE="submit" class="form-button" VALUE="PHP to go here">
    </FORM>
    PHP Code:
    <?php echo $this->__('There are <a href="%s"><strong>% items</strong></a> in your cart.'$this->getUrl('chkout/cart1'), $_cart1Quantity?>
    Both these work fine if they are separated from each other but when i put them together like the one below it stops functioning.

    Code:
    <FORM METHOD="LINK" ACTION="../chkout/cart1/">
    		<INPUT TYPE="submit" class="form-button" VALUE="<?php echo $this->__('There are <a href="%s"><strong>%s items</strong></a> in your cart.', $this->getUrl('chkout/cart1'), $_cart1Quantity) ?>">
              </FORM>
    So suggest some solution so that i can insert PHP code in to an HTML Button ?
    Last edited by Camdean; 06-01-2010 at 09:27 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Inserting PHP into button

    Well according to me you cannot use the anchor tag i.e. the <a> inside the button's value attribute. Also you will have to change the text that is outputted by the PHP if you want to display it inside the button than try to remove the html from it. please specify your problem more specifically

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Inserting PHP into button

    Please specify the actual output which you are getting and also specify the output which you want from the html. I think that there is something invalid in your program or function. If you specify it in more details then it will be more easier for me to implement on this problem. If possible try to post the whole program.

  4. #4
    Join Date
    Dec 2009
    Posts
    48

    Re: Inserting PHP into button

    Well i think that i have posted enough codes so that you can easily implement any way i would like to thanks you all and hence i followed the steps suggested by praetor and posting the code below

    Code:
    <FORM METHOD="LINK" ACTION="../chkout/cart1/">
    		<INPUT TYPE="submit" class="form-button" VALUE="<?php echo $this->__('There are <strong>%s items</strong> in your cart.', $this->getUrl('chkout/cart1'), $_cartQuantity) ?>">
              </FORM>
    But i have still not got the solution.

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: Inserting PHP into button

    In the html the buttons do not work with the links. They are usually used for submitting forms that is It's the action value for the form that decides where the form will be submitted to. I would like to know what the function actually returns and the method you are calling the functions. If you show me the full source code i can help you in this case since it is difficult to implement on this problem with such small segment of code.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Inserting PHP into button

    hello friend firstly i would like to tell you that you have provided enough information so that any one can implement on a problem like this also try to replace your code with the below code:

    Code:
    <button class="form-button" type="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')">
    <span><?php echo $this->__('Cart: <a href="%s"><strong>%s items</strong></a>', $this->getUrl('chkout/cart1'), $_cart1Quantity) ?></span>
    </button>
    I hope that your problem is fixed!!!!

Similar Threads

  1. Replies: 7
    Last Post: 05-12-2011, 09:25 PM
  2. Replies: 12
    Last Post: 26-09-2011, 11:01 PM
  3. Showing 16 GB when inserting new 250 GB HDD
    By AbeAalOma in forum Hardware Peripherals
    Replies: 5
    Last Post: 25-06-2011, 09:52 PM
  4. Replies: 3
    Last Post: 06-04-2011, 08:24 AM
  5. Convert Sleep Button in Shutdown button In Vista
    By Kraker999 in forum Customize Desktop
    Replies: 3
    Last Post: 19-03-2009, 11:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,242,606.75575 seconds with 17 queries