html - textbox.value not working in javascript -


the following simple javascript code set value textbox. but, doesn't seem work. not able find flaw. also, javascript working in ie , not in chrome/firefox. how out of trouble?

<!doctype html> <html>     <head>     <script type="text/javascript">         function reportvalue()         {             var form = document.getelementbyid("billgen");             var radioarray = form["time"];             var months;             for(var i=0;i<radioarray.length;i++)             {                 if(radioarray[i].checked)                 {                        months = radioarray[i].value;                     break;                 }             }             if(months == "1")             {                   e=31*100;                 form["total"].value = e;                     //document.getelementbyid("total").value = e; => not working                 return true;             }               else{             alert("are sure instructor " + months + "?\nyou may underestimating instructor!");             return false;             }            }     </script>     </head>     <body bgcolor="white">         <fieldset>             <legend>bill generation</legend>             <form id="billgen" method="post">                 <label><input type="radio" name="time" value="1" checked /> 1 month </label>                 <label><input type="radio" name="time" value="3" /> 3 month </label>                 <label><input type="radio" name="time" value="6" /> 6 month </label>                 <label><input type="radio" name="time" value="12" /> 1 year </label>                 <input type="submit" value="submit" onclick="reportvalue();" />                 <p>                             <input type="text" id="total" name="total" />                 </p>             </form>                  </fieldset>          </body> </html> 

clicing on <input type="submit"/> causes page reload, instead of "submit", either use <button> element or use <input type="button"/>.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -