dc_jt Posted March 14, 2008 Share Posted March 14, 2008 Hi Im trying to submit two forms using one onclick function but it seems to be only submitting the 'delivery_address_details' form and not the payment_details form. However if I comment out the 'delivery_address_details' form then it does submit the other form. Please see my code below: Thanks <SCRIPT LANGUAGE="JavaScript"> <!-- function submitForms() { document.payment_details.submit(); document.delivery_address_details.submit(); } //--> </SCRIPT> <form name="delivery_address_details" action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data"> <input type="hidden" name="checkout_mode" value="set_delivery" /> <input type="hidden" name="mode" value="select_address" /> <input type="hidden" name="address_id" value="0" /> <h2>Select an Address for Delivery</h2> <?php $oTblUser = new RCLUser(); $oTblUserLogin = new RCLUserLogin($_SESSION['shop_user_id']); $aDetails = $oTblUser->getUser($_SESSION['shop_user_id']); if(sizeof($aDetails['delivery_addresses'])>0){ $address_count = 0; foreach($aDetails['delivery_addresses'] as $address){ ?> <div class="row"> <input name="delivery_address" class="" type="radio" value="<?=$address['user_info_id']?>" <? if($_SESSION['shop_user_delivery_address']==$address['user_info_id']){echo('checked');}?> /> <?=$address['address'][1]?>,<?=$address['address'][2]?>, <? if($address['address'][3]){echo $address['address'][3].',';}?> <?=$address['city']?> <?=$address['postcode']?> </div> <? $address_count++; } }?> <!--<a href="#" id="submit_button" onclick="document.delivery_address_details.submit();">Use Selected Address</a>--> </form> <form name="payment_details" action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data"> <input type="hidden" name="checkout_mode" value="submit_payment" <?/*value="confirmation"*/?> /> <input type="hidden" name="mode" value="submit_payment" /> <div class="step-col"><h2>Payment Details</h2> <label for="startdate">Card Type</label> <select name="CardType" id="cardtype" class="frmfield-dates"> <option value="" selected="selected">-- Select --</option> <option value="MC"<?=($_REQUEST['CardType'] == 'MC') ? ' SELECTED' : '' ?>>Mastercard</option> <option value="VISA"<?=($_REQUEST['CardType'] == 'VISA') ? ' SELECTED' : '' ?>>Visa</option> <option value="DELTA"<?=($_REQUEST['CardType'] == 'DELTA') ? ' SELECTED' : '' ?>>Visa Debit</option> <option value="UKE"<?=($_REQUEST['CardType'] == 'UKE') ? ' SELECTED' : '' ?>>Visa Electron</option> <? /*<option value="MAESTRO"<?=($_REQUEST['CardType'] == 'MAESTRO') ? ' SELECTED' : '' ?>>Maestro</option>*/?> <option value="SWITCH"<?=($_REQUEST['CardType'] == 'SWITCH') ? ' SELECTED' : '' ?>>Maestro</option> <option value="AMEX"<?=($_REQUEST['CardType'] == 'AMEX') ? ' SELECTED' : '' ?>>Amex</option> <option value="DELTA"<?=($_REQUEST['CardType'] == 'DELTA') ? ' SELECTED' : '' ?>>Delta</option> </select> <label for="cardholder">Name on Card</label> <input name="CardHolder" type="text" id="cardholder" class="frmfield" value="<?=$_REQUEST[CardHolder]?>"/><br /> <label for="cardnumber">Card Number</label> <input name="CardNumber" type="text" id="cardnumber" class="frmfield" value="<?=$_REQUEST['CardNumber']?>" size="25"/><br /> <label for="securitynumber">Security Number</label> <input name="CV2" type="text" id="securitynumber" class="frmfield-small" value="<?=$_REQUEST[CV2]?>" size="3" maxlength="3"/> <a href="#"><img src="/assets/images/shop/help-ico.gif" alt="help" width="24" height="16" border="0" onclick="MM_openBrWindow('/creditcard-info.html','cardimg','width=400,height=310')" /></a><!--<span class="security-no-q">Where is this located?</span>--><br /> <label for="startdate">Start Date</label> <select name="ccValM" id="validmonth" class="frmfield-dates"> <option value="" selected="selected">Month</option> <option <?=($_REQUEST['ccValM']=='01') ? 'selected' : '' ?>>01</option> <option <?=($_REQUEST['ccValM']=='02') ? 'selected' : '' ?>>02</option> <option <?=($_REQUEST['ccValM']=='03') ? 'selected' : '' ?>>03</option> <option <?=($_REQUEST['ccValM']=='04') ? 'selected' : '' ?>>04</option> <option <?=($_REQUEST['ccValM']=='05') ? 'selected' : '' ?>>05</option> <option <?=($_REQUEST['ccValM']=='06') ? 'selected' : '' ?>>06</option> <option <?=($_REQUEST['ccValM']=='07') ? 'selected' : '' ?>>07</option> <option <?=($_REQUEST['ccValM']=='08') ? 'selected' : '' ?>>08</option> <option <?=($_REQUEST['ccValM']=='09') ? 'selected' : '' ?>>09</option> <option <?=($_REQUEST['ccValM']=='10') ? 'selected' : '' ?>>10</option> <option <?=($_REQUEST['ccValM']=='11') ? 'selected' : '' ?>>11</option> <option <?=($_REQUEST['ccValM']=='12') ? 'selected' : '' ?>>12</option> </select> <select name="ccValY" id="validyear" class="frmfield-dates"> <option value="" selected="selected">Year</option> <? for($year=(date("Y")-5); $year<(date("Y")+1); $year++) { ?> <option <?=($_REQUEST['ccValY']==substr($year,-2,2)) ? 'selected' : '' ?>> <?=substr($year,-2,2)?> </option> <? }?> </select><br /> <label for="expirydate">Expiry Date</label> <select name="ccExpM" id="expiresmonth1" class="frmfield-dates"> <option value="" selected="selected">Month</option> <option <?=($_REQUEST['ccExpM']=='01') ? 'selected' : '' ?>>01</option> <option <?=($_REQUEST['ccExpM']=='02') ? 'selected' : '' ?>>02</option> <option <?=($_REQUEST['ccExpM']=='03') ? 'selected' : '' ?>>03</option> <option <?=($_REQUEST['ccExpM']=='04') ? 'selected' : '' ?>>04</option> <option <?=($_REQUEST['ccExpM']=='05') ? 'selected' : '' ?>>05</option> <option <?=($_REQUEST['ccExpM']=='06') ? 'selected' : '' ?>>06</option> <option <?=($_REQUEST['ccExpM']=='07') ? 'selected' : '' ?>>07</option> <option <?=($_REQUEST['ccExpM']=='08') ? 'selected' : '' ?>>08</option> <option <?=($_REQUEST['ccExpM']=='09') ? 'selected' : '' ?>>09</option> <option <?=($_REQUEST['ccExpM']=='10') ? 'selected' : '' ?>>10</option> <option <?=($_REQUEST['ccExpM']=='11') ? 'selected' : '' ?>>11</option> <option <?=($_REQUEST['ccExpM']=='12') ? 'selected' : '' ?>>12</option> </select> <select name="ccExpY" id="expiresyear1" class="frmfield-dates"> <option value="" selected="selected">Year</option> <? for($year=(date("Y")-5); $year<(date("Y")+5); $year++) { ?> <option <?=($_REQUEST['ccExpY']==substr($year,-2,2)) ? 'selected' : '' ?>> <?=substr($year,-2,2)?> </option> <? }?> </select><br /> <label for="issuenumber">Issue Number</label> <input name="IssueNumber" type="text" id="issuenumber" class="frmfield-small" value="<?=$_REQUEST[issueNumber]?>"/><br /> <a href="#" id="submit_button" onclick="submitForms()">Make Payment</a> </form> Quote Link to comment Share on other sites More sharing options...
lordfrikk Posted March 14, 2008 Share Posted March 14, 2008 If am correct I think this is not possible. Just join those two forms into one. Quote Link to comment Share on other sites More sharing options...
samshel Posted March 14, 2008 Share Posted March 14, 2008 Hi, I agree with lordfrikk. It is not possible. I assume you want 2 different forms to be submitted as you have 2 different logics to execute. You will have to merge them in one file and submit a merged form to that file. Thanks SamShel Quote Link to comment Share on other sites More sharing options...
dc_jt Posted March 14, 2008 Author Share Posted March 14, 2008 ok thanks for your replies Quote Link to comment 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.