Hello!
I’m trying to trigger submit when a user clicks enter in the form submission.
This is the code I have so far but it’s not working:
export function input2_keyPress(event) {
let key = event.key
if (key === ‘Enter’ ){submitForm()}
Here’s a screenshot of the landing page:
The form field is called #input2
It links to a Form page that collects the email addresses.
The submit button is #button1
Any help will be appreciated! Thank you.
Hello to hello!
Perhaps this works for you…
exportfunction input2_keyPress(event) {
let pressedKey = (event.key).toString()
if(pressedKey==="Enter") {submitForm()}
}
And how do look like your —> {submitForm()} function ?
To check if your Submit-Button fires up the {submitForm()}-finction, to can implement a console-log to check if it works…
submitForm(){
console.log("Submission started!")
}
Hello there! Thank you so much for your response.
I just tried what you said and this is the error that i’m getting. Any ideas on how I could fix this?
(Error: submitForm is not defined)
Again, thank you so much!
@hello64250
This was also my question…
And how do look like your —> {submitForm()} function ?
You have any —> {submitForm()} function ! ! ! That means nothing will happen, because you have NO-function. How should this work ?
You have to write a function called ----> submitForm()
Did you put in this code part into your project…?
submitForm(){
console.log("Submission started!")
}
This will be your function, you will have to code it.
Do a test and take a look onto console. After pressing “Enter” you should be able to see the message → “Submission started!”
When this is working your first part is done.
Now you have to code your function… using either the DATASET-save-function or one of the DATA-COLLECTION-functions —> save/insert/update.
In this post you will have an good explained example, how to do that…
https://www.wix.com/corvid/forum/community-discussion/enquiries-on-displaying-information-within-a-lightbox-obtained-from-a-content-database/p-1/dl-5f52793193b103001757c904-5f51f720871caa0017ede944-1?commentId=5f51f720871caa0017ede944&origin=notification&postId=5f51eb04833c4f00173833c6&replyId=5f52793193b103001757c904
Good luck and happy coding.
-
Set the text input “onKeyPress”
-
Add this code:
export function Suchleiste_keyPress(event) {
if (event.key === "Enter") {
//and your code / the name of your function();
}
}
@Nick
Das wird ihm wohl nicht viel bringen, anscheinend fehlt ihm wohl die gesamte Funktion.
Your suggestion should normaly work. But it will not work, if {submitForm()} is an empty function.
@russian-dima Dann weis ich auch nicht weiter…
Maybe you find some tutorials in the internet.