douzhong8856 2013-09-07 07:15
浏览 12
已采纳

忽略表格中隐藏的跨度[重复]

This question already has an answer here:

I have a relatively simple need. I have an html form that contains a dynamic drop down that I built by using JS. When the first select is changed, a second (dependent) select appears. For example, the first select includes options for Ford, Toyota, and Honda. If the user selects "Ford" then another dropdown appears and allows the user to choose a model made by Ford (i.e. F150, Ranger, Fusion, etc...). I am using hidden <span> elements to show/hide the dependent drop downs, but the select name for all of the secondary drop downs is the same.

The issue is that when I submit my form, I get all three "make" variables passed through my $_GET method. I have included an example for clarity:

<span class="Ford">
    <select name="make">
        <option>F150</option>
        <option>Ranger</option>
        <option>Fusion</option>
    </select>
</span>
<span class="Toyota">
    <select name="make">
        <option>Prius</option>
        <option>Tacoma</option>
    </select>
</span>
<span class="Honda">
    <select name="make">
        <option>Civic</option>
        <option>Accord</option>
    </select>
</span>

The JS function just shows/hides the various spans as appropriate... All I want to do is pass the variable in the span that is currently showing on the page. Any ideas would be great!

</div>
  • 写回答

1条回答 默认 最新

  • dougai3418 2013-09-07 07:23
    关注

    You can add disabled="disabled" attribute to each hidden field, that way you will prevent them from being sent to the server.

    The idea is taken from the following Answer

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'