Jump to content

Need advice on how to get user input


keytone

Recommended Posts

Hi everyone.

I was planning to not trouble anyone with questions for a while, but....

 

I don't want anyone writing the code for me, just, a point in the right direction.

 

What I want to do is have a simple input form for a viewer to enter a few words of info, but I haven't even got a clue on where the info would go. How's that for ignorant?

 

I have some pics that a viewer could identify and tell me what they are. If I make an input form, I don't know where the entered info goes. Sounds pretty dumb, huh?

 

I am eager to learn how, but don't know where to start. Am I looking at learning php or database or both or what?

Just a nudge in the right direction would be a great help! I am always open-minded and welcome constructive advice.

Thanks very much, keytone

 

Link to comment
Share on other sites

You could have the user enter something that is then e-mailed to you, or you could store the user input into a file or the database. Either choice requires server-side code.

 

Maybe it would be better to do something that would produce a temporary visual effect. See...

 

http://www.w3schools.com/js/js_output.asp

 

http://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_inner_html

Link to comment
Share on other sites

We can modify that 2nd example to read some user input...

<!DOCTYPE html><html><body><h1>What Can JavaScript Do?</h1><input type="text" id="input1"/><button type="button" onclick="dosomething();">Click Me!</button><div id="output1">JavaScript can read inputs and display outputs.</div><script>function dosomething(){   document.getElementById('output1').innerHTML = document.getElementById('input1').value;}</script></body></html>

We can put that into a neater and more standard form like this...

<!DOCTYPE html><head lang="en"><meta charset="utf-8"><title>Jiffy Pop Memories</title><style>#output1{color: #F80;font-size:32pt;}</style><script>function dosomething(){  var inpv = document.getElementById('input1').value;  document.getElementById('output1').innerHTML = 'The input was [' + inpv + ']';  alert('The input was [' + inpv + ']');}</script></head><body><h1>What Can JavaScript Do?</h1><input type="text" id="input1"/><button type="button" onclick="dosomething();">Click Me!</button><div id="output1">JavaScript can read inputs and display outputs.</div></body></html>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...