javascript - selecting from dropdown list does not populate a second dependent drop list because of browser warning -


this first post on stack overflow, novice visit answers on question can't find existing answer helps me - because of limited knowledge.

my website uses prebuilt shop application - support no longer available - have modified extensively on number of years. there checkout pages feature dropdown country , second dependent dropdown state.

i removed dropdowns entirely long time ago because of problem behaviour couldn't fix have reinstate dropdowns (and problem code) because payment gateway changing standardised country code , state code requirement.

what happens when selection made country dropdown, code submits form before selection can made states dropdown; @ point browser puts alert asking confirmation want leave page on.

if answer 'no' stuck because states dropdown remains empty , in case form's buttons (next, back, cancelled) nothing. on other hand if answer 'yes' next checkout form loaded in browser , in form have use button go first form states dropdown populated , can make selection, use 'next' button etc. not viable process user because answer 'no' , stuck.

here's relevant part of code:

<tr>     <td class="kt_th"><label for="country_ord">country:</label></td>     <td>         <select name="country_ord" id="country_ord" onchange="submitme(this)">             <option value="" >choose one...</option>                 <?php                      {                   ?>                 <option value="<?php echo $row_rscountry['iso2_cnt']?>"<?php if (!(strcmp($row_rscountry['iso2_cnt'], $row_rsorder_ord['country_ord']))) {echo "selected";} ?>>                 <?php echo $row_rscountry['name_cnt']?></option>                 <?php                     } while ($row_rscountry = mysql_fetch_assoc($rscountry));                     $rows = mysql_num_rows($rscountry);                     if($rows > 0) {                         mysql_data_seek($rscountry, 0);                         $row_rscountry = mysql_fetch_assoc($rscountry);                     }                 ?>         </select>           <?php echo $tngs->displayfielderror("order_ord", "country_ord"); ?>     </td> </tr> <tr>     <td class="kt_th"><label for="state_ord">state (required usa only):</label (optional)></td>     <td>         <select name="state_ord" id="state_ord">             <option value="">choose 1 ...</option> <?php  {   ?>             <option value="<?php echo $row_rsstates['code_sta']?>"<?php if (!(strcmp($row_rsstates['code_sta'], $row_rsorder_ord['state_ord']))) {echo "selected";} ?>><?php echo $row_rsstates['name_sta']?></option>           <?php } while ($row_rsstates = mysql_fetch_assoc($rsstates));   $rows = mysql_num_rows($rsstates);   if($rows > 0) {       mysql_data_seek($rsstates, 0);   $row_rsstates = mysql_fetch_assoc($rsstates);   } ?>         </select>           <?php echo $tngs->displayfielderror("order_ord", "state_ord"); ?>     </td> </tr> <tr class="kt_buttons">     <td colspan="2">         <input type="button" onclick="mm_gotourl('parent','index.php?mod=cartview');return document.mm_returnvalue" value="&lt; previous">         <input type="submit" name="kt_update1" id="kt_update1" value="next &gt;">         <input name="button_cancel" type="button" value="cancel" onclick="document.location = 'index.php?mod=cartview'">         <input type="hidden" name="validate_form" value="1">     </td> </tr> </table> </form> <script> function submitme(el)  { var frm = el.form; frm.action = window.location.href; frm.elements.state_ord.selectedindex = 0; frm.elements.validate_form.value = 0; kt_fvo = {}; frm.elements.kt_update1.click(); } </script> 

to prevent submitting when value of pull-down selected remove this:

 onchange="submitme(this)"  this: <select name="country_ord" id="country_ord" onchange="submitme(this)">  this: <select name="country_ord" id="country_ord"> 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -