user393273
user393273

Reputation: 1438

Set input text box to data then submit to php

Basically i have a textbox on my .html page

<input name="points" type="text" id="points" value=""/>

and in the .js that gets called just onsubmit

document.getElementById('points').value = creator.showData();

i actually see with my eyes that the text is being added to the textbox however the php isn't reading the $_POST however if i manually enter the text into the same text box it works.

Any Ideas ? been screwing with my head all morning XD

Upvotes: 1

Views: 1692

Answers (1)

alex
alex

Reputation: 490433

It probably submits the form before the value is set.

Try this...

(function() {    
    var submitted = false;
    form.onsubmit = function(event) {
        if (submitted) {
            return true;
        }
        event.preventDefault();
        document.getElementById('points').value = creator.showData();
        submitted = true;
        form.submit();
    }
})();

Upvotes: 1

Related Questions