How can I say if the dropdown list has been selected then add the value or text to a textarea?

lulu50
lulu50 used Ask the Experts™
on
Hi,

How can I say if the dropdown list has been selected then append the value or the text to the textarea box.

I'm using bootstrap dropdown list.

  $("#AppendConditionBtn").click(function () {

            var RangeBoxFrom = $("#RangeBoxFrom").val().length;
            var RangeBoxTo = $("#RangeBoxTo").val().length;
            var GetOperatorSelectValue = $("#OperatorSelect option:selected").val();
            var GetConditionSelectValue = $("#ConditionSelect option:selected").text();
            var GetValueSelectValue = $("#ValueSelect option:selected").val();
            var GetGroupSelectValue = $("#GroupSelect option:selected").text();
            var GetItemsTextAreaValue = $("#ItemsTextArea").val();
            var GetOperatorSelectForRangeValue = $("#OperatorSelectForRange option:selected").val();
            var GetConditionSelectForRangeValue = $("#ConditionSelectForRange option:selected").val();
            var GetValueSelectForRangeValue = $("#ValueSelectForRange option:selected").val();
            var GetRangeBoxFromValue = $("#RangeBoxFrom").val();
            var GetRangeBoxToValue = $("#RangeBoxTo").val();

             if (RangeBoxFrom > 6 || RangeBoxTo > 6) {
                 alert("Range should be less than 6 character");
                 return false;
             }

// Here how can I say if the multiselectbox list has been selected then append the value or text to the "ContidionsAndAttributesTextArea"
otherwise don't append. 

             $("#ContidionsAndAttributesTextArea").val(GetOperatorSelectValue + " " + GetConditionSelectValue
                 + " " + GetValueSelectValue + " " + GetGroupSelectValue + " (" + GetItemsTextAreaValue + ") "
             + GetOperatorSelectForRangeValue + " " + GetConditionSelectForRangeValue + " " + GetValueSelectForRangeValue
             + " (" + GetRangeBoxFromValue + " - " + GetRangeBoxToValue + ") ");

 
              return true;

        });

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
MontoyaProcess Improvement Mgr

Commented:
Hi there,

To clarify, are you saying that you want to capture the value of an item in a dropdown list? Or, are you trying to say that if the dropdown list itself has focus?
lulu50Web application

Author

Commented:
Hi,

I want to say this:

if (GetOperatorSelectValue  != "")
{
   //append "GetOperatorSelectValue"  value to the  $("#ContidionsAndAttributesTextArea").val()
}
if(GetConditionSelectValue != "")
{
   //append "GetConditionSelectValue "  value to the  $("#ContidionsAndAttributesTextArea").val()
}
                 
etc...

I just want to add the values to the textarea if the user selected them
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
https://jsbin.com/xalabepowe/edit?html,output
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
  <select id="test" multiple>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
  </select>
  
  <textarea id="results"></textarea>
  
  
  
<script src="https://code.jquery.com/jquery-git.js"></script>
<script>
$(function(){
 
  $('#test').on('change',function(){
    var test=$(this).val();
    $('#results').val(test);
  });
});  
</script>
</body>
</html>

Open in new window

lulu50Web application

Author

Commented:
Thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial