Tenaciousmug Posted May 24, 2012 Share Posted May 24, 2012 Okay I am doing a banking system. I have a deposit and withdraw submit button in the same form.. thing is. When they are entering into the deposit field and hit "enter", it works fine since I guess the deposit is the default submit button. When they fill in the withdraw and hit "enter", it tries to enter for the deposit button. I want it when they are on the withdraw input field and hit enter, to submit the "withdraw" button, not the deposit. How do I go about doing this? I feel like it's something with Javascript or something. <form action="'.$_SERVER['SCRIPT_NAME'].'" method="post"> <div class="row clearfix"> <div class="two-row left"> <label>Deposit: </label> <input type="text" name="deposit_amt" /> </div> <div class="two-row"> <label>Withdraw: </label> <input type="text" name="withdraw_amt" /> </div> </div> <div class="row clearfix"> <div class="two-row left"> <input type="hidden" name="account" value="'.$bank['bank_name'].'" /> <input type="submit" name="deposit" value="Deposit" class="button" /> </div> <div class="two-row"> <input type="hidden" name="account" value="'.$bank['bank_name'].'" /> <input type="submit" name="withdraw" value="Withdraw" class="button" /> </div> </div> </form> I already tried rearranging the form so the deposit button is after the deposit input field and the withdraw button is after the withdraw input field, but it doesnt do anything. Quote Link to comment https://forums.phpfreaks.com/topic/263065-on-enter-submit-second-form-submit/ Share on other sites More sharing options...
Barand Posted May 24, 2012 Share Posted May 24, 2012 try giving both submit buttons the same name, say btnSubmit, then test the value switch ($_POST['btnSubmit']) { case 'Deposit': // deposit code break; case 'Withdraw': // withdrawal code break; } Quote Link to comment https://forums.phpfreaks.com/topic/263065-on-enter-submit-second-form-submit/#findComment-1348354 Share on other sites More sharing options...
Tenaciousmug Posted May 24, 2012 Author Share Posted May 24, 2012 It still reads the deposit because it is making that the default submit button.. it's not even recognizing hitting the second one unless you click it.. which most people will hit enter, so I need this to work. Thanks though! Quote Link to comment https://forums.phpfreaks.com/topic/263065-on-enter-submit-second-form-submit/#findComment-1348357 Share on other sites More sharing options...
Barand Posted May 24, 2012 Share Posted May 24, 2012 Split into two forms, maybe? Quote Link to comment https://forums.phpfreaks.com/topic/263065-on-enter-submit-second-form-submit/#findComment-1348366 Share on other sites More sharing options...
Jessica Posted May 24, 2012 Share Posted May 24, 2012 Yeah use two forms. Quote Link to comment https://forums.phpfreaks.com/topic/263065-on-enter-submit-second-form-submit/#findComment-1348368 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.