Saturday 15 May 2010

Javascript to enable, disable drop down menu in JSP file having Java code only, no HTML directly -


Let me introduce the design.

Each field in a JSP is created by a map . The name of the label, input type (drop down or other), input value, default value, etc. is added to map , say Map nameAttributes . Another class is general authors , which I do not have access to, which takes the value from map , parses them and writes the appropriate HTML code.

After writing the map, writer.writeSelectBox (nameAttributes); It is called .

Now, the requirement:
is a drop-down menu, depending on its chosen value, some other drop-down menus are disabled (shown in the UI but not modified) Or enable it. Since, I am not writing HTML code for additional fields, I can not write the function call event to do my work.

I have noticed that the JS function is called on onMouseOut event from the field, as shown in "View Source" . So I thought I could write my code to see the field value and affect other drop-down menu. But if I type warning in the JS function (check only), this will not warn me, this means that the function is not called and I can not write the enabled / debable code.

Is there any way to get a job? Enabling and disabling should depend on the user how to select from one of the drop-downs.

Sample code:

  & lt;% map name = newHashmop (); NameAttr.put (GeneralConst.INPUT_MESSAGE, Const.MSG_FIELD_NAME); // ..... Author. All selected box (named etter); & Gt%;   

Need immediate help, thanks.

See the JSP page, it is clear that some areas of Change and On-HouseOut Event etc. , And in the GeneralWriter class, those things are being written as outside stream like

  out.println ("& lt; td Abrap> Selection Name = "+ strName"); Out.println ("style = \" width: "+ strWidth +" px \ ""); Out.println ("On Change =" + On Change);   

So, instead of using the existing code I added my own method and introduced an on-change event. The type of " On Change " which you are looking for (right one) is java.lang.String and it was to be passed by JSP, as the behavior I wanted I want to do special work to call or call for a particular JSP.

Now I added the following to JSP

  & lt; Body & gt; & Lt; Script & gt; Window.onload = setModeForPara2 ('MemberTip','EmberState ',' Ceccestatus'); Function reset (event) {setModeForPara2 ('MEMBERTYPE', 'EMBARTSTATE', 'Ceccestatus'); } & Lt; / Script & gt; & Lt; / Body & gt;   

Where are the names of the criteria drop down menu, and setModeForPara2 () is an incompetence / js function to enable because my requirement is in the original post I went . It checks whether the merchandise is 0, then the incompetent state and gray color to be presented in the Amberstate and Cequestats drop-down menu, otherwise enable them and remove the gray color.
resetevent (uri) There is also a JS function called when the reset button is clicked to present the state to the disabled state and the status field.

Thus, the setModeForPara2 () function is called whenever: 1 page has been loaded,
2. Change the value of the first drop-down (MMEBARTEEE) Is, and 3 The reset button is clicked. Solution of



No comments:

Post a Comment