ThinkkSo
ThinkkSo

Reputation: 169

How can I submit div data to MySQL

I was wondering how can I submit div data to MySQL. Im not used to javascript so I dont really know whats happening on the javascript part but how can I get or input the action="" part and method="" part and can I or should I add value="" to the hidden input???

Form html code:

<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>

Upvotes: 1

Views: 425

Answers (1)

Devesh
Devesh

Reputation: 4550

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;" />

Upvotes: 2

Related Questions