<form id="storetable" autocomplete="off" action="" method="post"> <label>STORE:</label> <input type="text" list="storeID" name="store" placeholder="Choose a store..." required> <datalist id="storeID"> <option value="cwb_coins">Causeway Bay</option> <option value="wc_coins">Wan Chai</option> <option value="lck_coins">Lai Chi Kok</option> <option value="tp_coins">Tai Po</option> </datalist> </form
<script> $(document).ready(function(){ $("#storeID").change(function(){ var url = $(this).children(":selected").text(); //get the selected option value switch (url) { case "cwb_coins": $("#storetable").attr('action','cwb_coin_code.php'); //changing action attribute of form to cwb_coin_code.php break; case "wc_coins": $("#storetable").attr('action','wc_coin_code.php'); break; case "lck_coins": $("#storetable").attr('action','lck_coin_code.php'); break; case "tp_coins": $("#storetable").attr('action','tp_coin_code.php'); break; default: $("#storetable").attr('action', '#'); } }); }); </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)