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</sp开发者_Go百科an>
<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
You can't. You'll have to add some hidden inputs, and modify them from Javascript, to get them server-side. PHP can't access to the HTML, and only inputs elements are posted.
精彩评论