html onsubmit doesn't start Javascript function -


I have a javascript population collection of cacheable items, and a text box that has an id is user. I want to submit the form to redirect the user to the JSON response from the rest of the call on the form. The remaining URL works when I go directly to the browser but transfer the HTML and JS is killing me Nothing does nothing when submitting the form on submission

My form -

  & lt; Form id = "query" action = "get" onsubmit = "return restLink ();" & Gt; & Lt; TD & gt; & Lt; Select ID = "Selectable Etym Type" & gt; & Lt; Options & gt; Choose a cache worthy item type & lt; / Option & gt; & Lt; / Select & gt; & Lt; / TD & gt; & Lt; TD & gt; Cacheable Item ID: & lt; Input type = "text" id = "cacheableId" & gt; & Lt; Br> & Lt; / TD & gt; & Lt; / Form & gt;  

The type of the cache item is populated here -

  window.onload = function cacheItemType () {var select = document.getElementById ("selectable type" Type); Var option = ["1", "2", "3", "4", "5", "6", "7"]; (Var i = 0; i & lt; options.length; i ++) for {var opt = option [i]; Var el = document.createElement ("Options"); El.textContent = opt; El.value = opt. Select.appendChild (L); }};  

and the rest of the links () function -

  function rest link () {cachetypename = document.getElementyId ('Selectable eTime Type'). GetValue (); Cacheid = document.getElementyId ('cacheableId'). GetValue (); Return window.location.href = "http: // localhost: 8080 / rest / query /" + cacheTypem + "/" + cached; }  

Any help is greatly appreciated.

You are trying to set Window.location.href to either the form of this URL Want to deposit Or you do not need a form and just have to change the location in this url. You are combining 2 things and this is the reason that it is not working. I have to get rid of and just click on your onclick to create a button with your rest link () method does not require any form here.

Something like this:

  & lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Select ID = "Selectable Etym Type" & gt; & Lt; Options & gt; Choose a cache worthy item type & lt; / Option & gt; & Lt; / Select & gt; & Lt; / TD & gt; & Lt; TD & gt; Cacheable Item ID: & lt; Input type = "text" id = "cacheableId" & gt; & Lt; Br> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Input type = "button" id = "enterButton" onclick = "restLink ()" & gt; & Lt; / TR & gt; & Lt; / Table & gt;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -