Saturday 15 September 2012

html onsubmit doesn't start Javascript function -



html onsubmit doesn't start Javascript function -

i have form javascript populated collection of cacheable items, , text box id entered user. want on form submit redirect user json response rest call. rest url works when come in straight browser transferring html , js beating me. form on submit nil when submit clicked.

my form -

<form id="query" action="get" onsubmit="return restlink();"> <td> <select id="selectcacheableitemtype"> <option>select cacheable item type</option> </select> </td> <td> cacheable item id: <input type="text" id="cacheableid"><br> </td> </form>

the cacheable item type populated here -

window.onload = function cacheitemtype(){ var select = document.getelementbyid("selectcacheableitemtype"); var options = ["1", "2", "3", "4", "5", "6","7"]; for(var = 0; < options.length; i++) { var opt = options[i]; var el = document.createelement("option"); el.textcontent = opt; el.value = opt; select.appendchild(el); } };

and restlink() function -

function restlink() { cachetypename = document.getelementyid('selectcacheableitemtype').getvalue(); cacheid = document.getelementyid('cacheableid').getvalue(); homecoming window.location.href = "http://localhost:8080/rest/query/"+ cachetypename + "/" + cacheid; }

any help much appreciated.

you trying set window.location.href. either want submit form url. or don't need form @ , want alter location url. combining 2 things , why isn't working. rid of , create button onclick calling restlink() method. no need form here.

something this:

<table> <tr> <td> <select id="selectcacheableitemtype"> <option>select cacheable item type</option> </select> </td> <td> cacheable item id: <input type="text" id="cacheableid"><br> </td> </tr> <tr> <input type="button" id="enterbutton" onclick="restlink()"> </tr> </table>

javascript html forms

No comments:

Post a Comment