pleek Posted February 24, 2009 Share Posted February 24, 2009 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? Quote Link to comment Share on other sites More sharing options...
webster08 Posted February 24, 2009 Share Posted February 24, 2009 sure it does; set your input field from hidden to text and you will see for yourself. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted February 24, 2009 Share Posted February 24, 2009 <style type="text/css"> /*<![CDATA[*/ input.c1 {visibility: hidden;} /*]]>*/ </style> <input type="text" id="donation" name="amount" value="0.00" class="c1" /> Quote Link to comment Share on other sites More sharing options...
webster08 Posted February 24, 2009 Share Posted February 24, 2009 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. Quote Link to comment Share on other sites More sharing options...
pleek Posted February 25, 2009 Author Share Posted February 25, 2009 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. Quote Link to comment Share on other sites More sharing options...
webster08 Posted February 25, 2009 Share Posted February 25, 2009 it does change it; i know for a fact it does, because i have done this before and i tested the example i proved before i posted the idea for you. but whatever works - glad you got it to work out Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.