0

I want to check which value I selected in a scriplet, when I press some value in the drop down list. How can I do that?

I tried as follows : ( below two codes are in the same page "test.jsp" )

code : for list 
    <select id="stream" name="current_session" onclick="fun2()" >
                <option value="Winter">Winter</option>
                <option value="Monsoon">Monsoon</option>
    </select>

code : scriplet inside a javascript ( note that both html, scriplet are in the same page )

     <script>
     function  fun2(){

     <%  
       String given_session=request.getParameter("stream"); 
       system.out.println(given_session);
     %>

    }

note : I am getting output as null, instead of selected session value. So how can get the selected values in scriplet which is in the same jsp page?

1 Answer 1

0

you can use a js to select the value

function get_the_value(){

var e = document.getElementById('stream').value;

return e; }

In your web browser you have only html, javascript and css. All JSP code is meant to be run on the server. So you get only the output of the jsp file. And after this you cannot change the jsp code.

Sign up to request clarification or add additional context in comments.

3 Comments

khalid , if you dont mind can u give me some code for in ajax to do this action , since i want to do some operation at serverside based on the value i selected in the drop list, how could i get these selected value into scriplet to do serverside logic. ?
OFCOURSE ITS SO HARD TO GIVE A YOU CODE ,DIFFERENT SPECIFICATION , YOU HAVE TO SEARCH , SO START NOW : stackoverflow.com/questions/11645517/ajax-on-auiselect-liferay/… @user2870368

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.