Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  23] [ 6]  / answers: 1 / hits: 44278  / 11 Years ago, thu, march 21, 2013, 12:00:00

What I've done is:



HTML



<form>
<div id=textBox contenteditable=true name=textBox><?php echo $storyText; ?>
</div>
<textarea id=hiddeninput name=hiddeninput></textarea>
<input type=submit id=save name=save value=Submit/>
</form>


Javascript



$('#save').click(function () {
var mysave = $('#textBox').html();
$('#hiddeninput').val(mysave);
$(form:first).submit();
$('#hiddeninput').append(mysave);
alert($('#hiddeninput').val());
});


So both the alert and the append display the correct information, but it won't save #hiddeninput as a php variable when I submit. Originally I had this as an hidden input method, but I'm trying to show that it won't post no matter what I do,


More From » php

 Answers
23

Your code is working almost as it is.
But I'd rather use normal <input type=hidden> and you don't need to trigger submit for your form in your case just put the value in a hidden field.



Given your markup, with slight modifications



<form action=showrequest.php>
<div id=textBox contenteditable=true name=textBox style=width:300px;height:100px;>
</div>
<textarea id=hiddeninput name=hiddeninput></textarea>
<input type=submit id=save name=save value=Submit/>
</form>


js



$(function(){
$('#save').click(function () {
var mysave = $('#textBox').html();
$('#hiddeninput').val(mysave);
});
});


var_dump($_REQUEST) on php side gives



array(2) {
[hiddeninput]=>
string(4) test
[save]=>
string(6) Submit
}

[#79448] Wednesday, March 20, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondd

Total Points: 620
Total Questions: 112
Total Answers: 94

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
raymondd questions
Thu, Apr 22, 21, 00:00, 3 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
Thu, Jul 25, 19, 00:00, 5 Years ago
;