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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.