2018-07-16 17:45
采纳率: 0%
浏览 126


I am trying to set default value in a list box from the values in the table. The values are getting populated in the listbox from the database and the values in the table are hard coded. Can anybody help me with this?

  <td align="center">
  <a href="#" onclick="setExperienceValue("experience", "1")">1</a><br>
  <a href="#" onclick="setExperienceValue()">2</a><br>
  <a href="#" onclick="setExperienceValue()">3</a><br>
<select class="form-control  input-lg" id="experience"name="experience" 
  placeholder="Experience (in Years)" required="">
 <option value="">Experience: </option>
              $sql="SELECT * FROM experience";
              if($result->num_rows > 0) {
                while($row = $result->fetch_assoc()) {
                  echo "<option value='".$row['value']."' data- 
        <script type="text/javascript">
        function setExperienceValue () {                            
          var element = document.getElementById(id);
          element.value = val;


I am trying to set the default value in the listbox when the link in the table is clicked. How to populate the default value in such case?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题