0

i created an input from javascript like this:

<form action='' method='post' name='create'>
    <span id="duration"></span>
</form>


function duration(){
        document.getElementById('duration').innerHTML += "<label>Deadline  :</label><input type='date' name='deadline' id='deadline' onchange='pengumuman(this.value)' class='form-control' min=" + date('now', 0, 'ymd') + " max=" + date('now', 7, 'ymd') + ">";
        }

And i created a span inside a form, but whenever I tried to submit this form and print I got no value (string(0) = "") or $_GET['deadline']; (and i just tried $_POST['deadline'] also but still the same. not found Undefined index: deadline from this input. How to fix this? Do created input from javascript can't be inputted in form?

2
  • 2
    I'm not a PHP dev, however, I think you need to use: $_POST['deadline']; Commented Feb 17, 2018 at 11:38
  • Can you share your php code? Also, there is no submit button in your form so how you are posting the form? Commented Feb 17, 2018 at 11:48

1 Answer 1

1

POST parameters come in on $_POST, not $_GET. $_GET is for GET parameters. Since your form has method='post', it will send its data via POST.


The min=" + date('now', 0, 'ymd') + " max=" + date('now', 7, 'ymd') + part of your code also looks suspect, unless you've defined a JavaScript function alled date.

Sign up to request clarification or add additional context in comments.

2 Comments

I just tried your suggestion and it still the same, i got Undefined index: deadline. And function on min and max attribute are nothing to do with it cause it works like a charm.
@AdiHanifSedar: Show the code you're getting that error from. We can't help you with code we can't see.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.