How to use HTML forms without a server

后端 未结 6 528
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 08:49

I am not a web-developer and want to understand the better way to pass variables. In the past I have used various ways to pass things to java script functions. I have never

6条回答
  •  情歌与酒
    2021-01-14 09:13

    Yes you absolutely can use forms/inputs/any kind of html element and never talk to a server, just don't expect to store that data! You're right about using events (like the onsubmit one you mentioned) to trigger Javascript functions.

    Here is a quick and dirty example (heavy on the dirty) that does sorta kinda what you'd like. Note that instead of waiting for the form to be submitted before the color change, I go ahead and do it immediately after they choose a gender from the dropdown.

    http://jsfiddle.net/wG8K4/1/

提交回复
热议问题