forms - Fetching HTML input from text and drop down menu in Javascript? -
I want to give users two input mechanisms - using the element, text entry and drop down menu. The input value is taken in javascript. I can work on every method, but not together. This is probably the fundamental question, but can someone else tell me what is the cost for each input for event handlers as well as this input? Both your selected element and your text input element have the same ID. Make them unique and make a call for each element in your JS. Also, get rid of an onsubmit event handler feature in your selected element.
& lt; Form name = "myform" onsubmit = "return userInput ()" & gt; & Lt; Id = "myVal" onchange = "userInput ()" onsubmit = "return user input ()" & gt; & Lt; Options & gt; Select a country & lt; / Options & gt; & Lt; Option value = "all countries" & gt; All countries & lt; / Options & gt; & Lt; Option value = "Austriaia" & gt; Austria & lt; / Options & gt; & Lt; Option value = "Korea" & gt; Korea & lt; / Options & gt; & Lt; Option value = "Austria" & gt; Austria & lt; / Options & gt; & Lt; Option value = "United States" & gt; United States & lt; / Options & gt; & Lt; Option value = "Japan" & gt; Japan & lt; / Options & gt; & Lt; Option value = "Canada" & gt; Canada & lt; / Options & gt; & Lt; Option value = "India" & gt; India & lt; / Options & gt; & Lt; / Select & gt; & Lt ;! - & lt; Input name = "submit" type = "submit" value = "add to list" & gt; - & gt; & Lt; Input type = "text" id = "myVal" placeholder = "add some text & hellip;" & Gt; & Lt; / Form & gt; // Javascript code where I'm bringing user input Function user input (event) {userinput = document.getElementById ("myVal"). Value // console.log (userinput) // console.log (document.getElementById ("myVal"). Value) //draw(document.getElementById ("MyVal"). Value) d3.select ('svg'). Remove (); Main(); Console.log ("called main") // Draw (document.getElementById ("myVal"). Value) return false; }
Comments
Post a Comment