-1

I am trying to get text and selected value from checked radio button and put it into variable. Trying to get something like "Is published" or if is other radio checked to be like "Is not In Review". This needs to be plain javascript - no jquery or any other framework.

    <form>
      <div class="filter-option">
        <input type="radio" id="status" name="status" checked="checked"/>
        <label for="status">Is</label>
        <div class="searchFilter">
          <select class="selectpicker" title="" data-size="false" multiple 
          data-live-search="true">
          <option value="all">All</option>
          <option value="published">Published</option>
          <option value="draft">Draft</option>
          <option value="in-review">In Review</option>
          <option value="deleted">Deleted</option>
        </select>
      </div>
    </div>
    <div class="filter-option">
      <input type="radio" id="is_not" name="status"/>
      <label for="is_not">Is not</label>
      <div class="searchFilter">
        <select class="selectpicker" title="" data-size="false" multiple data- 
        live-search="true">
          <option value="all">All</option>
          <option value="published">Published</option>
          <option value="draft">Draft</option>
          <option value="in-review">In Review</option>
          <option value="deleted">Deleted</option>
        </select>
      </div>
      </div>
      <div class="filter-option">
        <input type="radio" id="contain" name="author"/>
        <label for="contain">Contain</label>
        <div class="searchFilter">
          <input type="text" class="simpleSearch">
        </div>
      </div>
    </form>
Denis Omerovic
  • 1,420
  • 1
  • 10
  • 23
  • Possible duplicate of [Get selected value in dropdown list using JavaScript?](https://stackoverflow.com/questions/1085801/get-selected-value-in-dropdown-list-using-javascript) – dbac Sep 09 '18 at 17:19
  • What have you done to solve this problem? We're here to *help* you solve and understand your problems, not to provide free code. – David Thomas Sep 09 '18 at 17:31

1 Answers1

1

You give the select element an id, then use document.getElementById(id).value.
This should return the value of the selected option, which you can then use any way you want.
Using .text instead gives you the text shown to the user in the list (in this example they are the same).

dbac
  • 328
  • 1
  • 10
  • by the way, I just noticed the question is a duplicate of https://stackoverflow.com/questions/1085801/get-selected-value-in-dropdown-list-using-javascript – dbac Sep 09 '18 at 17:20