javascript - jsp pass variables between two pages -


in main jsp page, have

<%@ include file="../customparametershorizontal.jsp" %>  <tr> <td align="center" class="reportparamsgeneratebuttoncell"> <html:submit onclick="if(pregeneratecriteria()){return true;} else {return false;}">generate</html:submit> </td> </tr> 

within customparametershorizontal.jsp, there include dateselection1.jsp, validates date , time set on form.

 <script> function validatehhmm(inputfield, message) {     var isvalid = /^(0?[1-9]|1[012])(:[0-5]\d) [apap][mm]$/.test(inputfield);      if (isvalid) {      }else {         alert("time must entered in format hh:mm am/pm");      }      return isvalid; } </script> 

so, within dateselection1.jsp, tried disable button in main jsp using :

 document.form1.reportparamsgeneratebuttoncell.disabled= true; 

but, error saying object null or not defined.

is there anyway, can set var, can chacked main form , disable button accordingly?

here's way it, retaining <html:submit> tag, , without introducing jquery: first, add styleid attribute button has html id can grab onto:

<html:submit styleid="my_submit" onclick="if(pregeneratecriteria()){return true;} else {return false;}">generate</html:submit> 

next, use id element of dom , disable it:

var elt = document.getelementbyid("my_submit"); elt.disabled = true; 

update

if understand original question correctly, main.jsp includes customparametershorizontal.jsp, whici includes dateselection1.jsp. 3 scripts rendering 1 html page, hence 1 document object.

i see (partial) code 1 <form> on html page. if have more 1 form, .getelementbyid() works across dom elements in forms, opposed document.form1 style of accessing elements.

be sure call validatehhmm() @ appropriate point enable/disable submit button, , make sure button re-enabled once user corrects input make valid.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -