Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP Post not passing Variable when using JS

  • 12-04-2011 11:38am
    #1
    Registered Users, Registered Users 2 Posts: 378 ✭✭


    Hi guys

    As part of my form, a user is allowed to pick a "closing date" using a JS calender

    Here is the JS Script:

    <script type="text/javascript" src="js/jsDatePick.min.1.3.js"></script>
    <script type="text/javascript">
    window.onload = function(){
    new JsDatePick({
    useMode:2,
    target:"closingdate",
    dateFormat:"%d-%m-%Y"
    });
    };
    </script>


    and the form input:

    <input type="text" name="closingdate" style="width: 260px" value ="'.$closingdate.'" id="closingdate"></input>


    When I select my date, and post the date, the variable is not carried accross

    If I remove the id="closindate", and manually enter something into the text box, it works fine, that way I know its the JS that is causing the variable not to POST

    Any help at all would be greatly appreciated

    Many thanks in advance


Comments

  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    [php]<input type="text" name="closingdate" style="width: 260px" value ="'.$closingdate.'" id="closingdate"></input>[/php]

    Can you give more info on this. Is this printed as a PHP string? - otherwise you won't get the value of $closingdata as it's not interpreted by PHP.


  • Registered Users, Registered Users 2 Posts: 378 ✭✭bob2oo7


    Webmonkey wrote: »
    [php]<input type="text" name="closingdate" style="width: 260px" value ="'.$closingdate.'" id="closingdate"></input>[/php]Can you give more info on this. Is this printed as a PHP string? - otherwise you won't get the value of $closingdata as it's not interpreted by PHP.

    Hi Webmonkey

    This is indeed printed and it variable works perfectly fine if I dont use JS, all other variables within the form are passed except this one


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    What happens if you don't load the date thing and leave in the id="closingdate" and manually enter it. Does that work?


  • Registered Users, Registered Users 2 Posts: 378 ✭✭bob2oo7


    Webmonkey wrote: »
    What happens if you don't load the date thing and leave in the id="closingdate" and manually enter it. Does that work?

    It does indeed, works perfectly fine


  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    <input type="text" name="closingdate" style="width: 260px" value ="'.$closingdate.'" id="closingdate"></input>

    Doesn't the PHP variable need to be enclosed in PHP tags? (<?php ?>)

    Maybe I'm mistaken...


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 378 ✭✭bob2oo7


    Hi Dave

    You are correct, I didnt post all my code on here but the entire page is in closed in PHP tags


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭Freddio


    Are you looking at it in IE - if so do you have javascript errors prior to what you quoted? also is the date format of the javascript compatible with any sql behind the form?


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Check the error console for errors in your browser. Surely it will show something. I think I used that date picker thing before without any problems on a site.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    If you pick the date and not submit the form, can you see the date in the field ?


  • Registered Users, Registered Users 2 Posts: 378 ✭✭bob2oo7


    Thanks for the replies guys

    I got this sorted

    I needed to put the JS code in the head of the page that is calling the function, I only had it in the page that the function is on (if that makes sense)

    All sorted now and working

    Appreciate the help and guidance


  • Advertisement
Advertisement