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:
<inputtype="hidden" name="label-value" value="innerHTML"/>
This will add label-value
to the post
hash.
Solution 2:
Just use like this after label
<inputtype='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?
<formaction="script.php"><labelfor="name">
Some Name
</label><inputid="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><inputtype="hidden"name="label-text"value="Some text">
Post a Comment for "Take Innerhtml Value With Post Method Php"