PHP POST一个变量值

时间:2016-06-20 17:13:52

标签: javascript php jquery html

我有一个表单,为Any,All或至少提供选择框选项。如果您选择“至少”,则JavaScript(如下所示)会触发第二个选择框,并允许您从选中的复选框数中进行选择。我怎样才能让我的至少?选项值等于至少:数字被选中?因此,当表单发布时,它至少发布:1,至少:3,等等。

这是我的HTML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
<!ELEMENT policymap (policy)+>
<!ELEMENT policy (#PCDATA)>
<!ATTLIST policy domain (delegate|coder|filter|path|resource) #IMPLIED>
<!ATTLIST policy name CDATA #IMPLIED>
<!ATTLIST policy rights CDATA #IMPLIED>
<!ATTLIST policy pattern CDATA #IMPLIED>
<!ATTLIST policy value CDATA #IMPLIED>
]>
<!--
  Configure ImageMagick policies.

  Domains include system, delegate, coder, filter, path, or resource.

  Rights include none, read, write, and execute.  Use | to combine them,
  for example: "read | write" to permit read from, or write to, a path.

  Use a glob expression as a pattern.

  Suppose we do not want users to process MPEG video images:

    <policy domain="delegate" rights="none" pattern="mpeg:decode" />

  Here we do not want users reading images from HTTP:

    <policy domain="coder" rights="none" pattern="HTTP" />

  Lets prevent users from executing any image filters:

    <policy domain="filter" rights="none" pattern="*" />

  The /repository file system is restricted to read only.  We use a glob
  expression to match all paths that start with /repository:

    <policy domain="path" rights="read" pattern="/repository/*" />

  Any large image is cached to disk rather than memory:

  Define arguments for the memory, map, area, and disk resources with
  SI prefixes (.e.g 100MB).  In addition, resource policies are maximums for
  each instance of ImageMagick (e.g. policy memory limit 1GB, -limit 2GB
  exceeds policy maximum so memory limit is 1GB).
-->
<policymap>
  <!-- <policy domain="system" name="precision" value="6"/> -->
  <!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
  <!-- <policy domain="resource" name="memory" value="2GiB"/> -->
  <!-- <policy domain="resource" name="map" value="4GiB"/> -->
  <!-- <policy domain="resource" name="area" value="1GB"/> -->
  <!-- <policy domain="resource" name="disk" value="16EB"/> -->
  <!-- <policy domain="resource" name="file" value="768"/> -->
  <!-- <policy domain="resource" name="thread" value="4"/> -->
  <!-- <policy domain="resource" name="throttle" value="0"/> -->
  <!-- <policy domain="resource" name="time" value="3600"/> -->
  <policy domain="coder" rights="none" pattern="EPHEMERAL" />
  <policy domain="coder" rights="none" pattern="URL" />
  <policy domain="coder" rights="none" pattern="HTTPS" />
  <policy domain="coder" rights="none" pattern="MVG" />
  <policy domain="coder" rights="none" pattern="MSL" />
  <policy domain="coder" rights="none" pattern="TEXT" />
  <policy domain="coder" rights="none" pattern="SHOW" />
  <policy domain="coder" rights="none" pattern="WIN" />
  <policy domain="coder" rights="none" pattern="PLT" />
  <policy domain="path" rights="none" pattern="@*" />
</policymap>

这是触发第二个选择框的JavaScript,它根据检查的复选框数量提供可供选择的数字列表:

<select name="anyall" id="anyall" onchange="anyall_change()">
    <option value = "any"> Any </option>
    <option value = "all"> All </option>
    <option value = "atleast"> At Least... </option>
</select>
<span id="atleast_div" style="display:none"></span>

我花了很多时间试图弄清楚没有运气。我知道您不能将选项值设置为等于变量,因此您必须能够以某种方式使用PHP附加它。希望得到一些帮助,谢谢!

1 个答案:

答案 0 :(得分:1)

您可以将select的选项值更改为带有'atleast:'字符串的前缀,并使用PHP获取该值。

示例:

opts += 'value="atleast:'+(i+1)+'">'+(i+1)+'</option>';

在PHP方面,获取值:

<?php
echo $_POST['atleast_qty'];

希望这有帮助。