+ 3
Clear Input Button
How do I clear the input of my form After calling on a function to perform a calculation based on the users input
23 Answers
+ 7
i'll make a quick code...
+ 6
reference the DOM of your input and set the value = "" or " " when the calculation is complete [end of the function before closing it]
+ 6
are you using the <form> tag?
+ 6
user cyk got it ready and done ;)
+ 6
cyk's code clears the previous input on focus (when you click the input box).
its a lot nicer IMO but we'll help regardless
+ 6
cyk
Yeah lol it will require JS code; unless theres a CSS alternative but im no CSS guru
+ 6
cyk you want to help him or her make something simple?
+ 6
cyk yep that sounds like the solution ;)
+ 5
Here love. You've got your answer. Played around with one of the codes I posted earlier
https://code.sololearn.com/Ws19kJz1Bc72/?ref=app
+ 4
I didn't code it to do that. I only solved your "clear input field on button click issue"... The rest doesn't have much to do with JS per say, it is a function that gets the value of the input field and does a conversion and returns it. Give it a try and we will help if you get stuck. ☺
+ 3
Aaaaaah... You want the user to click on a button that will clear the field. Is that it?
+ 3
「HAPPY TO HELP」 Seems we were answering the wrong question? This needs JS code
+ 3
「HAPPY TO HELP」 love Nah. JS. Event handler for the clear button. We could also do in the button stuff in HTML, onclick="this.form.reset();". But the button will have to be with the input fields between form tags
+ 3
「HAPPY TO HELP」 Sure!...
+ 2
Here. Look at line 15 of the first code, the part that has to do with onfocus and line 16 of the second code, the part that has to do with onfocus. They both do what you want, kind of. Basically when the user clicks in the input field it is cleared and ready to receive new inputs
https://code.sololearn.com/Wte6t2yXQMvF/?ref=app
https://code.sololearn.com/WAMXplm993Bk/?ref=app
+ 2
Aight...thanks... Appreciate the help
+ 1
How would that look like
+ 1
Yes but when I do the solution disappears. The function is to convert Fahrenheit to Celsius and the clear the input
+ 1
Then
+ 1
I need a button to clear the input though