been struggling with this one what im trying to do is create a second hidden input field from the text in first depending on what is selected this is what ive tried:
<script>
var $extraval = $('#citycode option:selected').text();
var input = $("<input>").attr("type", "hidden").attr("name", "city").val("$extraval");
$('#form').append($(input));
</script>
this is what the first select looks like
<select id="citycode" name="citycode">
<option value="3439389">Asuncion</option>
<option value="3439352">Bella Vista</option>
<option value="3439101">Ciudad Del Este</option>
<option value="3438735">Encarnacion</option>
</select>
so basically what im trying to do is create a second hidden form input with the text of this select when submited as the value of the input
Assuming that it’s inside
#form, I found two errors:"when you try to setinputvalue passing$extravalas parameter..append(input)Try the following:
demo