I am really not sure where to start with this. I have a form input box and submit button. When the submit button is pressed, the form content is submitted and used in some javascript. What I want to do is automatically add some text to the end of the submission.
So if a user inputs "The dog walked" and pressed submit, the form would add "across the street." to the end of the submission.
Thank you!!
Open the form or report in Design view by right-clicking the form or report in the Navigation Pane, and then clicking Design View. On the Design tab, in the Controls group, click Text Box. Position the pointer where you want the text box to be placed on the form or report, and then click to insert the text box.
To sum up, to create a text input field in HTML, you need at least: An <input> element, which typically goes inside a <form> element. To set the type attribute to have a value of text . This will create a single line text input field.
If you only want to style a specific input type, you can use attribute selectors: input[type=text] - will only select text fields. input[type=password] - will only select password fields. input[type=number] - will only select number fields.
In your event listener for the form's submit action, change the input.
document.getElementById('theinputid').value = document.getElementById('theinputid').value + "across the street."
W3 schools is your friend: Form onsubmit Event
So in your case it's something similar to:
<script type="text/javascript">
function addText() {
var input = document.getElementById('something');
input.value = input.value +' across the street';
}
</script>
<form name="frm1" action="?" onsubmit="addText()">
<input type="text" name="somehting" id="something" />
<input type="submit" value="Submit" />
</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