1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Two Submit buttons on same page

Discussion in 'XenForo Development Discussions' started by AndyB, Dec 23, 2015.

  1. AndyB

    AndyB Well-Known Member

    Hello,

    I would like to have two Submit buttons on the same page like this:

    pic001.jpg

    The template code is:

    Code:
    <xen:title>{xen:phrase trader_trader_admin}</xen:title>
    
    <form action="{xen:link 'trader/adminseller'}" method="post" class="xenForm">
       
    <dl class="ctrlUnit">
        <dt><label>{xen:phrase trader_view_sellers_history_for}:</label></dt>
        <dd><input type="text" name="seller_name" size="50" class="textCtrl AutoComplete AcSingle" /></dd>
    </dl>   
    
    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" value="{xen:phrase trader_submit}" class="button primary" accesskey="s" /></dd>
    </dl>
    
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    
    </form>
    
    <br />
    
    <form action="{xen:link 'trader/adminbuyer'}" method="post" class="xenForm">
       
    <dl class="ctrlUnit">
        <dt><label>{xen:phrase trader_view_buyers_history_for}:</label></dt>
        <dd><input type="text" name="buyer_name" size="50" class="textCtrl AutoComplete AcSingle" /></dd>
    </dl>   
    
    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" value="{xen:phrase trader_submit}" class="button primary" accesskey="s" /></dd>
    </dl>
    
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    
    </form>
    
    I'm currently experiencing the second form action is being selected even though I'm clicking the first Submit button.

    Thank you.
     
    Last edited: Dec 23, 2015
  2. Jake B.

    Jake B. Well-Known Member

    Just do two separate forms
     
  3. AndyB

    AndyB Well-Known Member

    Got it.

    The trick is to have a unique value for the Submit.

    Code:
    <xen:title>{xen:phrase trader_trader_admin}</xen:title>
    
    <form action="{xen:link 'trader/adminseller'}" method="post" class="xenForm">
    	
    <dl class="ctrlUnit">
        <dt><label>{xen:phrase trader_view_sellers_history_for}:</label></dt>
        <dd><input type="text" name="seller_name" size="50" class="textCtrl AutoComplete AcSingle" /></dd>
    </dl>	
    
    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" value="{xen:phrase trader_submit_seller}" class="button primary" accesskey="s" /></dd>
    </dl>
    
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    
    </form>
    
    <br />
    
    <form action="{xen:link 'trader/adminbuyer'}" method="post" class="xenForm">
    	
    <dl class="ctrlUnit">
        <dt><label>{xen:phrase trader_view_buyers_history_for}:</label></dt>
        <dd><input type="text" name="buyer_name" size="50" class="textCtrl AutoComplete AcSingle" /></dd>
    </dl>	
    
    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" value="{xen:phrase trader_submit_buyer}" class="button primary" accesskey="s" /></dd>
    </dl>
    
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    
    </form>
    
     

Share This Page