Saving data from a text field after a user selects the option "others" in the drop-down list

I have a drop-down list in which the user will select the reason for the return. in the drop-down list there is an option "other", which displays a different text field for inserting other information. I already got the code to save the value from the drop-down list, but not the value in the text box if the user selects the "other" option. thank!

Here is my picture:

<td width="218">
  <select name="returnreason" id="returnreason"  onChange="others(this.value);">
    <option value="0"> --Select Return Reason-- </option>
    <option value="1">Damaged in transit</option>
    <option value="2">Wrong item delivered</option>
    <option value="3">Wrong item ordered</option>
    <option value="4">Demo/Service Unit</option>
    <option value="5">W/out warranty sticker</option>
    <option value="6">Does not work/broken (DOA)</option>
    <option value="7">Clients are not satisfied</option>
    <option value="8">Others</option>
  </select>
</td>

<div id="8" style="display:none;">
  Please specify <input type="text" id="8" name="8" class="forinput"/>
</div>

My js:

<script>
  $(document).ready(function() {
    $("#returnplus").hide();        
    $("#addreturn").click(function() { 
      $("#returnplus").show("slow");
    });
  }
</script>

Here to save in db:

$returnreason=isset($_POST['returnreason'])? $_POST['returnreason'] : '';
+4
source share
1 answer

Perhaps it

$r8 = isset($_POST['8'])? $_POST['8'] : '';

if( $returnreason == 8 ){
    $returnreason_specify = $r8;
}

I donโ€™t understand what you really want ...

, "8" $r8 = isset($_POST['8'])? $_POST['8'] : '';

0

Source: https://habr.com/ru/post/1548293/


All Articles