1

I have a form with different different button when ever i click it should submit same page it self

<?php if ($status != 'canceled'){?>

                                        <?php $orderIdForm = $order->getId(); ?>
                                        <form action="<?php echo $this->getUrl('mpshippingmanager/shipping/savetrackingnumber/',array('id' =>$orderIdForm))?>" id="shipping-form" method="post">
                                        <?php 
                                        $tracking=$this->getTrackingNumber($order->getId());
                                        if($tracking!=""){
                                            $disabled=$tracking->getTrackingNumber()==''? "":"readonly='readonly'";
                                            $shipmentId = $tracking->getShipmentId();
                                            $invoiceId=$tracking->getInvoiceId();
                                            $shippingamount=$tracking->getShippingCharges();
                                        }?>



                                    <div class="shipping_top" style="display:none">
                                        <span class="shipping_service"><?php echo $helper->__('Carrier');?></span>
                                        <span class="row_total"><?php echo $helper->__('Tracking Number');?></span>
                                    </div>
                                    <div class="items">
                                    <input class="required-entry" type="hidden" value="<?php echo $order->getId(); ?>" name="order_id"/>
                                    <div class="wk_item">
                                        <span class="carrier" style="display:none"><input class="required-entry carrier" value="<?php echo $tracking->getCarrierName(); ?>" <?php echo $disabled;?> type="text" name="carrier"/></span>
                                        <span class="row_total wk_track_input" style="display:none">
                                            <!-- <input value="<?php //echo $tracking->getTrackingNumber(); ?>" <?php //echo $disabled;?> type="text" name="tracking_id"/> -->
                                            <input value="0" type="text" name="tracking_id"/>
                                        </span>
                                        <div class="order-status">
                                        <?php if(count($shipping_coll)): ?>
                                            <?php if($status=="Ordered"): ?>
                                                <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/cancelorder',array('id'=>$mageorderid))?>">
                                                    <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Cancel Order') ?>" type="button" id="save_butn" >
                                                        <span><span><?php echo $helper->__('Cancel Order') ?></span></span>
                                                    </button>
                                                </a>
                                            <?php endif;  ?>
                                        <?php endif; ?>

                                        <?php if($status == "processing" ){?>

                                            <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Generate Invoice') ?>" type="submit" id="save_butn" >
                                                <span><span><?php echo $helper->__('Invoice') ?></span></span>
                                            </button>
                                        <?php } ?>


                                        <!-- Custom Order Status -->
                                        <?php if ($status == "Invoice"){?>

                                        <!-- <a href="<?php //echo $this->getUrl('mpshippingmanager/shipping/shipementorder',array('id'=>$orderIdForm))?>"> -->
                                          <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Shipment') ?>" type="submit" id="save_butn" >
                                          <span><span><?php echo $helper->__('Shipment') ?></span></span>
                                          </button>
                                        <!-- </a>  -->
                                        <?php }?>


                                        <?php if ($status == 'Shipement'){?>
                                        <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/rtoorder',array('id'=>$mageorderid))?>">
                                          <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('RTO') ?>" type="button" id="save_butn" >
                                          <span><span><?php echo $helper->__('RTO') ?></span></span>
                                          </button>
                                        </a>
                                        <?php }?>

                                        <!-- Custom Order Status -->





                                            </div>

                                            </div>
                                        </div>
                                    </form>

Here invoice button is working but Shipment not working. I am using wrong way can you please tell what is the problem in this?

  • post this method too savetrackingnumber problem in this method not in form. – Qaisar Satti Feb 2 '16 at 4:51
  • then what i need to use – Magento 2 Feb 2 '16 at 4:55
  • post in question so i can figured out where is the problem.. – Qaisar Satti Feb 2 '16 at 4:56
  • can i update the question??? – Magento 2 Feb 2 '16 at 4:57
  • yes you can update that.. – Qaisar Satti Feb 2 '16 at 4:58
0
 <?php if ($status == 'Shipement'){?> <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/rtoorder',array('id'=>$mageorderid))?>‌​"> <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('RTO') ?>" type="button" id="save_butn" > <span><span><?php echo $helper->__('RTO') ?></span></span> </button> </a> <?php }?> 

replace with

<?php if ($status == 'Shipement'){?> <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/rtoorder',array('id'=>$orderIdForm))?>‌​"> <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('RTO') ?>" type="button" id="save_butn" > <span><span><?php echo $helper->__('RTO') ?></span></span> </button> </a> <?php }?> 
| improve this answer | |
  • what is difference between my code and this – Magento 2 Feb 2 '16 at 5:26
  • you adding the wrong variable. the correct variable is $orderIdForm. the page is goes blank because of missing id.. – Qaisar Satti Feb 2 '16 at 5:27
  • i tried this also in yesterday anyway ok thank for your help – Magento 2 Feb 2 '16 at 5:29
  • glad i can help.. – Qaisar Satti Feb 2 '16 at 5:30
  • is it correct <?php if($invoiceId): ?> <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/printinvoice',array('id'=>$orderIdForm))?>"><button class="button wk_mp_btn wk_invoiceslip" title="<?php echo $helper->__('Invoice Slip') ?>" id="<?php echo $orderIdForm; ?>" style="float:right;"> <span><span><?php echo $helper->__('Invoice Slip') ?></span></span> </button></a> <?php endif; ?> it download invoice slip bt it redirect to blank page – Magento 2 Feb 2 '16 at 6:00
1

Try this:

<form action="<?php echo $this->getUrl('mpshippingmanager/shipping/savetrackingnumber/',array('id' =>$orderIdForm))?>" id="shipping-form" method="post">       

<?php if($status == "processing" ){?>
<button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Generate Invoice') ?>" type="submit" id="save_butn" >
<span><span><?php echo $helper->__('Invoice') ?></span></span>
</button>
<?php } ?>

<?php if ($status == "Invoice"){?>
<button style="" onclick="setLocation('<?php echo $this->getUrl('mpshippingmanager/shipping/shipementorder',array('id'=>$orderIdForm))?>')" class="button wk_mp_btn" type="button" title="<?php echo $helper->__('Shipment') ?>" id="id-wk-mp-btn"><span><span><?php echo $helper->__('Shipment') ?></span></span></button> 
<?php }?>

</form>
| improve this answer | |
  • 1
    No it's redirect in this domain.com/mpshippingmanager/shipping/savetrackingnumber/id/1986/ and it show blank page not submiting – Magento 2 Feb 2 '16 at 4:48
  • on click Shipment Button right?? – Abdul Feb 2 '16 at 4:55
  • yes it should not redirect, it should submit current page itself – Magento 2 Feb 2 '16 at 4:56
  • Pls add bellow code after </form> tag : <?php if ($status == "Invoice"){?> <button style="" onclick="setLocation('<?php echo $this->getUrl('mpshippingmanager/shipping/shipementorder',array('id'=>$orderIdForm))?>')" class="button wk_mp_btn" type="button" title="<?php echo $helper->__('Shipment') ?>" id="id-wk-mp-btn"><span><span><?php echo $helper->__('Shipment') ?></span></span></button> <?php }?> – Abdul Feb 2 '16 at 5:01
  • i added it load ajax not submiting – Magento 2 Feb 2 '16 at 5:04
0

You have a type="button" instead of type="submit"

| improve this answer | |
0

change your shipment button code from

<button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Shipment') ?>" type="button" id="save_butn" >

to

<button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Shipment') ?>" type="submit" id="save_butn" >
| improve this answer | |
  • As a note misspelling float won't help you with CSS – Mayers Feb 1 '16 at 14:27
  • it redirect not working – Magento 2 Feb 1 '16 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.