I have an input in html form and I need to send them to script. it has both name and id .
<p>
<select onchange="myFunction(this.value)" name="shippcity" id="shippcity">
<option value="0">state</option>
</select>
<input type="hidden" name="calc_shipping_city" id="shipping_city" value="" />// will be removed
</p>
<script>
function myFunction(val) {
if ( val === '' ) {
}
else {
//input val to name="calc_shipping_city" and id="shipping_city"
document.getElementById("shipping_city").value = val;
}
}
</script>
there is this code too from woocomerce:
<?php
}
$my_city = $woocommerce->customer->get_shipping_city();
$my_city = explode('-', $my_city);
if(isset($my_city) && intval($my_city[0]) > 0 ){
?>
set_initial_val('shipp', 'city', <?php echo $my_city[0]; ?>);