0

I have a JavaScript functionality that change the value dynamically on selecting a list box ,i am able to get that value in a text field using the id.But i want to get that value in a jsp variable that i am not able to get this is what i have done ,

          <div class="form-control">
                <label class="lebelMergin" for="_Manager">
                <span class="spanMergin"></span>
             <input type='text' class='text' name='business1' id="hiddenField" /> 
                </label>
            </div>     

jquery

$('#branch_branchTypeId').on('change', function (event) {
   //var vl = $("option:selected",this).text();
   var vl = $(this).val();      
   var myvalue=$("option:selected",this).text();
   $('.text').val(myvalue);
   document.getElementById("hiddenField").value=myvalue;

    var target = $("#business");
    if (vl) {
        target.show();
    } else {
        target.hide();
    }
}); 

This is showing the value in the div using id.but i want that id in a script variable.

Sudharsan S
  • 15,336
  • 3
  • 31
  • 49
lucifer
  • 2,297
  • 18
  • 58
  • 100

2 Answers2

1

The only ways is AJAX, use AJAX to make call to the server and send all your data along with it, possibly in JSON format.

Amit Malakar
  • 618
  • 1
  • 5
  • 10
0

Use of Jquery's load() will be the best solution which uses parameters and URL which to be called use this link to get more reference

Code snippet:

$.ajaxSetup({ cache: false }); $("#Divsection").load(URLofresourceofAjax,{ "param1OfRequest":value,"Param2":value});

Bhargav Modi
  • 2,605
  • 3
  • 29
  • 49