1

This is my demo.jsp page

<head>
    <script>           
        function source(key){
            var k=document.getElementById(key);
            var UserSelectedOption = k.options[k.selectedIndex].text;
            alert(UserSelectedOption);               
        }           
    </script>            

<body>
    <%
       //How can i get UserSelectedOption value here;
    %>
</body>

Here i'm getting UserSelectedOption is "hello",how can i use it inside jsp body page.thanks for your help.

Govind Singh
  • 15,282
  • 14
  • 72
  • 106
tajMahal
  • 418
  • 6
  • 18
  • 40
  • possible duplicate of [How do I pass JavaScript values to Scriptlet in JSP?](http://stackoverflow.com/questions/5701031/how-do-i-pass-javascript-values-to-scriptlet-in-jsp) – Thilo Apr 28 '14 at 06:35
  • is there any other way to do this?you suggested link is not working properly – tajMahal Apr 28 '14 at 06:39
  • it is still not clear what you want to achieve. Please be more specific – MaVRoSCy Apr 28 '14 at 06:49

1 Answers1

0

you have to only show the content, you can show in a div

<body>
   <div id="divId"></div>  
</body>

//-------//

function source(key){
            var k=document.getElementById(key);
            var UserSelectedOption = k.options[k.selectedIndex].text;
            alert(UserSelectedOption);               
            document.getElementById("divId").innerHTML=UserSelectedOption;
        }   
Govind Singh
  • 15,282
  • 14
  • 72
  • 106