html - Javascript code not working in Firefox -
i have dropdown list box. if user hasn't selected anything, should not go next page. tried something. code works fine in ie , chrome. it's going next page in firefox. why this?
<td width="100" align="right"> <div style="text-align:center;"> <input type="button" value="next" align="top" style="width: 70px;" onclick="gt();"> </div> </td> <script type="text/javascript"> function gt_nextpage() { var e=document.getelementbyid("parenttype"); var val=e.options[e.selectedindex].value; window.location.replace("gt_iba1?value="+val); } function gt() { var e=document.getelementbyid("parenttype"); var val=e.options[e.selectedindex].value; if(val != null) { gt_nextpage(); } if(val === "") { alert("please select value"); window.location.replace("gt_iba?value="+val); } } </script>
i have added inside jsp page.
try this
function gt() { var e=document.getelementbyid("parenttype"); var val=e.options[e.selectedindex].value; if(val != null && val !== "") { gt_nextpage(); } else { alert("please select value"); window.location.replace("gt_iba?value="+val); } }
Comments
Post a Comment