Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:48:55+00:00 2026-06-11T06:48:55+00:00

I have a play 2 framewrok project with java. In the view files ,

  • 0

I have a play 2 framewrok project with java.
In the view files , there is a drop down list which is populated by a method in the controller class.
In addition to the drop down list , I also have a json data structure that is populated by javascript methods and event listeners in the view file.
Now I want a way to add the selected item from the drop down list to the json object.
I have provided snippets of the codes below.

this is the code for the drop down list :

 <select class = "selectone">
  @for(gesture <- gesturesList){
      <option value = @gesture.id>
        @gesture.getName()
      </option>
  } 
  </select>

I have below code snippets from the the javascript and json object

 <script type="text/javascript" charset="utf-8">

     /* this is our websocket connection */       
var WS = window['MozWebSocket'] ? MozWebSocket : WebSocket
var socket = new WS("@routes.Application.webSocket().webSocketURL(request)")

/* this is the json object , it contains x and y coordinates from HTML5 canvas */              
          var jNode =  {"x":arrayX,"y":arrayY }  


 /* this is a jquery function for tranmitting  json object through the websocket */                        

        $('button.add').click(function() { 
             socket.send(JSON.stringify(jNode));})                                 
     </script>       
}

can someone kindly show me how to add the item selected from the drop down list to the json object so that we have something like the following in the json object:

var jNode = {“x”:arrayX,”y”:arrayY , “item” : Itemselected}

thank you all

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:48:56+00:00Added an answer on June 11, 2026 at 6:48 am

    You should realize that’s a JS+HTML topic, so showing Play’s view has no sense for JS geeks…

    Anyway as you are using jQuery, use it also to get the val(). BTW remember it should be placed inside some event (ie: click()) otherwise it will copy value which was set after page load and won’t change it):

     <select class = "selectone">
         <option value="0">Choose</option>
         <option value="1">Gest 1</option>
         <option value="2">Gest 2</option>
         <option value="3">Gest 3</option>
     </select>
    
     <script type="text/javascript" charset="utf-8">
          // ...
        $('button.add').click(function() { 
            var jNode = {"x":arrayX,"y":arrayY , "item" : $("select.selectone").val()};
            socket.send(JSON.stringify(jNode));
        });
          // ...                                 
     </script>   
    

    From val() API:

    $('select.foo option:selected').val();    // get the value from a dropdown select
    $('select.foo').val();                    // get the value from a dropdown select even easier
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller Foo in play framework scala project: In Foo controller (in
I use the Play Framework 2.0 (2.0.3). I have a Java project and want
I have a Play Framework (1.2.4) project with PlayMorphia that has two different database
I have a Play! framework Heroku project that has three deployments. One for running
hi there i am woring with java play framework and i want to implement
Is it possible to have both java and scala controllers and views in play
I am creating my first project using play framework on NetBeans and I have
i am working on project using play 2 framework with java. I want to
I have a working Play Framework project. I'm using Play Framework version number 1.2.5
Is it possible to integrate the play framework into an existing Java EE project?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.