PHP - 访问SPAN值 [英] PHP - Accessing SPAN values

查看:96
本文介绍了PHP - 访问SPAN值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP新手,但我正在为订单表单创建电子邮件脚本。



我拥有所有的值和不在表单中的内容,使用JavaScript访问客户端的文本元素。



当我POST时,我需要做的也是访问这些跨度值。 b
$ b

HTML:

 < form name =myformaction =submit.php method =post> 
< strong>价格:< / strong> $< span id =SMP> 11.99< / span>
< strong>价格:< / strong> $< span id =SDP> 11.99< / span>
< strong>价格:< / strong> $< span id =YTP> 11.99< / span>
< strong>价格:< / strong> $< span id =SDP> 11.99< / span>
//一串输入表单代码被截断为readabilty
< / form>


解决方案

你不能那样做。 POST数组将只包含通过输入字段发布的内容。最简单的事情就是在你的值中加入一些隐藏的输入

 < input type =hidden name =prices [0]value =11.99> 
< input type =hiddenname =prices [1]value =11.99>
< input type =hiddenname =prices [2]value =11.99>

这将在您的$ _POST数组中可用。您可以像访问它一样

  $ value1 = $ _POST ['prices'] [0]; 

或者只是将它迭代为一个数组


I'm new to PHP but I'm working on an email script for an order form.

I have all the values and what not in a form, with a text element that is span-ned for javascript access client side.

What I need to do is also access these span values when I POST.

HTML:

 <form name="myform" action="submit.php" method="post">
 <strong>Price:</strong> $<span id="SMP">11.99</span>
 <strong>Price:</strong> $<span id="SDP">11.99</span>
 <strong>Price:</strong> $<span id="YTP">11.99</span>
 <strong>Price:</strong> $<span id="SDP">11.99</span>
 //bunch of input form code i truncated for readabilty
 </form>

解决方案

You can't do that. The POST array will only contain what you post via input fields. Easiest thing for you to do would be to have some hidden inputs with your values in them

<input type="hidden" name="prices[0]" value ="11.99">
<input type="hidden" name="prices[1]" value ="11.99">
<input type="hidden" name="prices[2]" value ="11.99">

This will be available in your $_POST array. You can access it like

$value1 = $_POST['prices'][0];

Or just iterate it through as an array

这篇关于PHP - 访问SPAN值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆