简体   繁体   中英

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

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();
    }
})();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM