I am trying to update one hidden input field with another visible input field using javascript...
but my code doesn't work for some reason!!
This is my javascript:
<script language="javascript">
function process1() {
document.getElementById("sum_total").value = (document.getElementById("my-item-price").value);
}
</script>
And This Is My form code:
<form><input name="A1" type="text" class="A1" id="A1"/></form>
<form><input type="hidden" id="A2" name="A2" value="process1() "/></form>
Update
<script language="javascript">
function process1() {
document.getElementById("sum_total").value = (document.getElementById("my-item-price").value);
}
</script>
Use indexOf() into value string, searching for the desired key to find a starting position. Then remove the chars between starting position plus the lenght of key.
If you want to post an array you must use another notation: foreach ($postvalue as $value){ <input type="hidden" name="result[]" value="$value."> } Save this answer.
The code you have is bad. You haven´t got id
s you are looking for in javascript.
Try this:
<script language="javascript">
function process1(showed) {
document.getElementById("A2").value = showed.value;
}
</script>
<form><input name="A1" type="text" class="A1" onChange="process1(this)"/></form>
<form><input type="hidden" id="A2" name="A2" value="5" /></form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With