rocky3015 Posted September 11, 2008 Share Posted September 11, 2008 Hi! i need help....how do i display the value of a submit button in a text box. e.g. if i click on a submit button with value = "hello", how do i capture this value in a text box and display in the same text box? ??? Quote Link to comment https://forums.phpfreaks.com/topic/123720-submit-to-text-box/ Share on other sites More sharing options...
Zane Posted September 11, 2008 Share Posted September 11, 2008 Quote Link to comment https://forums.phpfreaks.com/topic/123720-submit-to-text-box/#findComment-638844 Share on other sites More sharing options...
obsidian Posted September 12, 2008 Share Posted September 12, 2008 <input type='submit' name='submitbuttonname' onSubmit='yourtextboxname.value=submitbuttonname.value' /> If I'm not mistaken, onsubmit is only a valid event for the form tag itself, not for individual input fields. If you want to capture it on submit, you can take this onsubmit attribute and put it as part of your form tag proper; however, you'll want to change "yourtextboxname.value" to "this.yourtextboxname.value" so the form can locate the field (same with submitbuttonname). Another option would be to handle it in an onclick handler for the submit button instead of the onsubmit. I would do it slightly different than recommended above, but it may just be a preference thing: <input type="submit" name="submitbuttonname" onclick="this.form.textareaname.value = this.value;" value="My Submit" /> Good luck! Quote Link to comment https://forums.phpfreaks.com/topic/123720-submit-to-text-box/#findComment-639813 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.