javascript - Pass an input box value through to a var in the js doc to be used -


Whether the value of an input from a form can be used in a spread in a function.

For example:

  & lt; Input type = "text" id = "userID" name = "userID" placeholder = "enter user id" style = "width: 200px;" / & Gt; & Lt; Input type = "submit" value = "search" />   

Then userID will be passed to:

  var userId = null;   

I'm looking to use it as a way to input the Flickr API call for the user.

  $ GetJSON ('http:? //api.flickr.com/services/rest/ method = flickr.photos.search & getSizes & api_key = feb7e93d9a90e9a734787bea9be81440 & user_id =' + userID + '& has_geo = 1 & amp; extras = geo & amp; format = json & jsoncallback =? ', Map images);   

I was seen around and

  var userId = document.getElementById ("userID") came to. Value;   

This does not work though.


I have tried:

  & lt; Form type = "post" onsubmit = "load images (); return back;" & gt; & Lt; Input type = "text" id = "userID" name = "userID" placeholder = "load user picture" /> & Lt; Input type = "submit" value = "get a flickr picture!" / & Gt; & Lt; / Form & gt; Usage of the function:  
  function load image () {var userId = document.getElementById ("userID"). Values; }   

Is it on the right track or completely closed?

getElementById is case-sensitive.

In your HTML you use "userID" and "userId" in your javascript.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -