I'm lost with this. First, I made an array in php (reason? Fetch all values of a column into an array, to use later) and "save" like this:
echo '<input type="hidden" name="hidden[]" id="hidden[]" value="'.$to_update.'">';
Then, I made a select with some values and chars, also constructed with php. Like this:
echo '<option value="'. $id .'">'. $desc .'</option>';
The fetched values are correct, $id
$desc
and $to_update
have the value I require.
Then, in php/html I have this code:
<select name="articulo" id="articulo" onchange="myFunc(this.value)">
<input name="updated" id="updated" type="text" />
So, when calling in js is like this (same html, after body tag):
<script >
function myFunc(val) {
var id = document.getElementById("updated");
var valor = document.getElementsByName("hidden");
id.value = valor[val].value;
}
</script>
So, for example, if in select Is 1, 2 and 3 values; one, two and three options, I want to change the input text called updated to another values, like a, b and c.
Is it a better way to do it, or just to fix some code?