Jump to content

[SOLVED] entering a donation amount and changing a input value


pleek

Recommended Posts

ok, i have this code

 

script type="text/javascript">
function changeText(){
var donationAmount = document.getElementById('amount').value;
document.getElementById('boldStuff').innerHTML = donationAmount;
document.getElementById('donation').value = donationAmount;
}
</script>

<input type="text" id="amount">
<input type='button' onclick='changeText()' value='Change Text'/>

<p>donate <b id='boldStuff'>$0.00</b> </p>      

<input type="hidden" id="donation" name="amount" value="0.00"/>

 

i didn't include the whole form, just the input for the amount. The form works by itself, and the 'boldstuff' amount changes with "changetext()". But it doesn't change the input value, what am i doing wrong?

you don't have to change the style of the input field; the text will automatically be inserted in the field whether it is a text input field or a hidden input field; but if you will just set it to text; you will see the value change for yourself. you can change it back to a hidden field; when you get done viewing the value change.

even with it hidden, the "changetext()" function doesn't change the value of the form, but something you posted did solve my problem. Just change the input to text instead of hidden and the user can just input what ever they want. thanks for the idea.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.