1

我想知道如何将 div 数据提交到 MySQL。我不习惯 javascript,所以我真的不知道 javascript 部分发生了什么,但是我如何获取或输入 action="" 部分和 method="" 部分,我可以或应该将 value="" 添加到隐藏输入???

表单html代码:

<form onsubmit="document.getElementById('hidden_data').value=document.getElementById('showing_data').innerHTML;">
        <input id="hidden_data" name="data" type="hidden"/>
        <div id="showing_data" class="commenttext" contenteditable="true"></div>
        <input type="submit" Value="Enter" id="submitthis">
</form>
4

1 回答 1

2

Use the hidden field inside the form tag and use the JavaScript to put the value inside it. You can get the hidden field in the $_POST['hydName'].
Put the data on the click of the submit button into the hidden field. Keep your action and method of the form same as required. After the click event is fired, it will submit the form to its action URL

<input type="submit" onclick="document.getElememtById('hidden').value = document.getElementById('div').innerHtml;" />
于 2013-10-10T05:40:44.813 回答