1

I'm running into a little problem on submitting an input text-field which should have value set by a javascript script.

this is my code for the form:

<html>
<head><title></title>
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
<link rel="stylesheet" type="text/css" href="stylingIndex.css" />
</head>
<body>

<div class="main">
<table border="0">
<form method="POST" action="begin.php?id=createfile">
<tr><td>Date 1</td>   
<td><input type="date" name="date1"></td></tr>
<tr><td>Date 2</td>
<td><input type="date" name="date2"></td></tr>
<tr><td><input type="submit" name="submit" value="Go"></td></tr>
</form>
</table>
</div>

<script>
$(":date").dateinput();
</script>
</body>
</html>

Whenever I check the $_POST value its empty. (the createfile.php is handling perfectly, that's not the problem), I think the problem is in the way i treat the Javascript but I don't know what I'm doing wrong.

It looks like it's not assigning the value selected (the date) from the script, although it does appear client side, it just doesn't process it after submitting. Hope anyone can help me.

14
  • Is jQuery included in the jQuery.tools.min.js file? Commented Jul 19, 2013 at 11:04
  • So, you are never seeing date1 or date2 being posted to begin.php? Commented Jul 19, 2013 at 11:05
  • :date refers to the date function in jquerytools called from line #4.Just to be clear: the javascript works, i can select a date perfectly fine, but when i submit it doesn't send the value i selected Commented Jul 19, 2013 at 11:05
  • What's with the crazy </script> tag after the <html> tag? Commented Jul 19, 2013 at 11:07
  • @putvande yes it does, its the complete query library + all tools Commented Jul 19, 2013 at 11:07

2 Answers 2

1

simply drag the start and end tag of the form:

<html>
<head><title></title>
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
<link rel="stylesheet" type="text/css" href="stylingIndex.css" />
</head>
<body>

<div class="main">
    <form method="POST" action="begin.php?id=createfile">
<table border="0">
<tr><td>Date 1</td>   
<td><input type="date" name="date1"></td></tr>
<tr><td>Date 2</td>
<td><input type="date" name="date2"></td></tr>
<tr><td><input type="submit" name="submit" value="Go"></td></tr>
</table>
    </form>
</div>

<script>
$(":date").dateinput();
</script>
</body>
</html>
Sign up to request clarification or add additional context in comments.

2 Comments

D'oh, can't believe I missed that!
It seems to be a small bug, but still unpleasant. =)
0

You definitely have some tidying up to do on your markup. Notice the closing of the input nodes. Could you just try this for me? Putting the script block up top and using the jQuery DOMready function?

JSFIDDLE

   <head>
   <script>
   $(function() {
       $(':date').dateinput();
   });
   </script>
   </head>
   <body>
        <div class="main">
            <table border="0">
                <form method="POST" action="begin.php?id=createfile">
                    <tr>
                        <td>Date 1</td>
                        <td>
                            <input type="date" name="date1" />
                        </td>
                    </tr>
                    <tr>
                        <td>Date 2</td>
                        <td>
                            <input type="date" name="date2" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" name="submit" value="Go" />
                        </td>
                    </tr>
                </form>
            </table>
        </div>

1 Comment

Thanks, that worked!! (sorry for not able to vote up not 15 rep yet). My thank is big and will do when i have 15.

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.