3 Replies Latest reply on Apr 15, 2010 3:42 AM by Ilya Shaikovsky

    Problem with HtmlSelectOneMenu onChange Event

    Kapil Nimje Newbie

      Hi

      I have a HtmlSelectOneMenu contains the list of item (response type), and I have another HtmlSelectItem drop down for Correct Anser, After chaning the value from response type select box i need to disabled the second Drop down (Correct Answe). All this is created in Java Custom classes.

       

      Please see the below code

       

      HtmlSelectOneMenu mnuResponseType = new HtmlSelectOneMenu();
                      mnuResponseType.setId(questionId + "ResponseTypeMenu");
                      mnuResponseType.setValueExpression("value", application.getExpressionFactory().createValueExpression(context.getELContext(), "#{projectBean.questions["+i+"].responseType}", String.class));
                      //mnuResponseType.setOnchange("updateQuestionnairePreview(event);setCorrectAnswerEnabled('"+questionId+"Panel');resetCorrectAnswer(document.getElementById('"+questionId+"CorrectAnswerMenu'), this.value == 2);");
                      mnuResponseType.setStyleClass("questionType");

       

                      UISelectItem itemRadioButton = new UISelectItem();
                      itemRadioButton.setId(questionId + "ResponseTypeMenu_RadioButton");
                      itemRadioButton.setItemValue(1);
                      itemRadioButton.setItemLabel("Select One (Radio Button)");
                      mnuResponseType.getChildren().add(itemRadioButton);

       

       

      HtmlSelectOneMenu mnuCorrectAnswer = new HtmlSelectOneMenu();
                      mnuCorrectAnswer.setId(questionId + "CorrectAnswerMenu");
                      mnuCorrectAnswer.setValueExpression("value", application.getExpressionFactory().createValueExpression(context.getELContext(), "#{projectBean.questions["+i+"].correctAnswer}", String.class));

       

                      mnuCorrectAnswer.setValueExpression("disabled", application.getExpressionFactory().createValueExpression(context.getELContext(), "#{projectBean.questions["+i+"].isMultiSelect}", Boolean.class));

       


                      //mnuCorrectAnswer.setOnchange("updateQuestionnairePreview(event);");
                      mnuCorrectAnswer.setStyleClass("correctAnswer");

       

                      UISelectItem itemOpinion = new UISelectItem();
                      itemOpinion.setId(questionId + "CorrectAnswerMenu_Opinion");
                      itemOpinion.setItemValue(0);
                      itemOpinion.setItemLabel("None (i.e., Opinion Based)");
                      mnuCorrectAnswer.getChildren().add(itemOpinion);

       

                      for (int j = 0; j < answers.size(); j++) {
                          UISelectItem item = new UISelectItem();
                          item.setId(questionId + "CorrectAnswerMenu_A" + (j));
                          item.setItemValue(j+1);
                          item.setItemLabel("" + (j+1));
                          mnuCorrectAnswer.getChildren().add(item);
                      }

       

      Kindly help to sort out this issue..

       

      Thanks

      Kapil