dtutlamjasblef7982 2013-05-17 08:11
浏览 44
已采纳

在PHP中从MYSQL获取数据时,在组合框中选择的属性的功能是什么

Hello i am beginner in PHP. I am trying to fetch data from MYSQL and want to show in combo box but if user does not re selects the item from item list it highlights error that nothing is selected. Is there any php function to do this particular task ? I want that when the data of particular id is loaded in form and if without making any change in combo boxes data user cliks on submit then it must submit but in my case it shows that the fields are empty while data is here. Here is my Code

<li id="foli3" class="notranslate      ">
<label class="desc" id="title3" for="Field3">
what is the current occupation of your guardian?
<span id="req_3" class="req">*</span>
</label>
<span>
    <select id="Field3" name="occupation" class="field select addr" tabindex="8" required >

        <option value="" selected="selected"><?php echo $rows['occupation']; ?></option>
                        <option>Private Sector Employee</option>
                        <option>Social Sector Employee</option>
                        <option>Agriculturalist</option>
                        <option>Businessman</option>
                        <option>Government Employee</option>
                        <option>Other</option>
    </select>
</span>
</li>
  • 写回答

2条回答 默认 最新

  • doubeiji2602 2013-05-17 08:17
    关注

    use jQuery to select default value for combo box.

    <select id="mySelect">
    <option value="foo">Foo</option>
    <option value="bar">Bar</option>
    <option value="quux">Quux</option>
    </select>
    
    $("#mySelect").val("quux");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图