I’m trying to make an html file that asks the user for three numbers then puts the input in separate variables to be used with the code… If anyone knows how please tell me…
did you want something like
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>prompt demo</title> </head> <body> <h1 id='demo'> </h1> <script> var name=prompt('your name please') document.getElementById("demo").innerHTML='your name is '+name </script> </body> </html>
Sorry no I meant to change what I said… What I meant was the user inputs three numbers and it gets put into separate variables to be used in the code… Sorry about that
It’s just the example how you can do that
so same way you can create three variable and ask users for input.
can i see your code what you’ve done so far?
Ok thanks I will try that and I can’t show you my code currently… But I will when I get the chance.
It worked Thank You:smiley:
I m so happy that you solved it
Wait would this be possible in a type of input?
<. Input. Type. =. “text”. >
<input type='text'> is absolutely possible.
How would I do it the code you gave me did not work
you still would need to write the code to make it work, your question was if it was possible. I confirmed that the use of
<input type='text'> is possible
well, we would need to make a button to allow the user to submit there entered text, then we would need either
onclick attribute on the
once we done this, we can retrieve the input from the field.
This is a lot more complicated then using the
prompt() function as you can see
we could use
var input = document.getElementById("input_id").value; to get the value of input field, where input_id is the id of your input field.
I took advantage of your mistake because to me this is what I need and its really helpful