Take InnerHTML Value With Post Method PHP
I want to take the innerHTML value of a label element in a form with method post and show it to another PHP page. But i have only work with that with textboxes, as an example in a
Solution 1:
You will need to use a hidden input:
<input type="hidden" name="label-value" value="innerHTML"/>
This will add label-value
to the post
hash.
Solution 2:
Just use like this after label
<input type='hidden' name='postname' value='labelvalue'/>
In php
<?php
$labelname = $_POST['postname'];
echo $labelname;
?>
that's it !
Solution 3:
Do you want to post "Some Name" to your php script?
<form action="script.php">
<label for="name">
Some Name
</label>
<input id="name" name="name">
</form>
If so you will need to add it as a hidden input:
Option 1: Using javascript
<script>
$(function() {
$('form').on('submit', function () {
var labelText = $(this).find('label').text();
$(this).append('<input type="hidden" name="label-text" value="' + labelText + '">');
});
});
</script>
Option 2:
Echo it together with the input field in your php.
<label>Some text</label>
<input type="hidden" name="label-text" value="Some text">
Post a Comment for "Take InnerHTML Value With Post Method PHP"