Loading ...
Sorry, an error occurred while loading the content.

Calendar & form posting

Expand Messages
  • samuel_feynman
    Hi, I m using the calendar on a form. The user clicks a date. I want the date that s clicked to be stored in a hidden form element, say, the_date . From there
    Message 1 of 6 , Apr 17, 2006
    • 0 Attachment
      Hi,

      I'm using the calendar on a form. The user clicks a date. I want the
      date that's clicked to be stored in a hidden form element, say,
      "the_date". From there the form can be submitted and "the_date"
      captured by the server.

      Here's what I have right now (not working):

      [form snippets:]
      <td><input type="hidden" id="the_date" name="the_date" />
      <div id="cal1Container"></div></td>

      <td><input name="click" type="submit" value="Add Job"
      onsubmit="this.the_date.value = cal1.getSelectedDates()"; /></td>
      </form>

      Of course, when I check the value of "the_date" on the server-side,
      it's blank.

      Any help is appreciated. I've been trying to figure this out for the
      last 6 hours already :(

      Thanks,
      Samuel
    • Marcus Engene
      ... Hi Samuel, I m off somewhere and have not time to test, but this refers to the item the event is firing on so this here is the submit-button and not the
      Message 2 of 6 , Apr 17, 2006
      • 0 Attachment
        samuel_feynman wrote:
        > Hi,
        >
        > I'm using the calendar on a form. The user clicks a date. I want the
        > date that's clicked to be stored in a hidden form element, say,
        > "the_date". From there the form can be submitted and "the_date"
        > captured by the server.
        >
        > Here's what I have right now (not working):
        >
        > [form snippets:]
        > <td><input type="hidden" id="the_date" name="the_date" />
        > <div id="cal1Container"></div></td>
        >
        > <td><input name="click" type="submit" value="Add Job"
        > onsubmit="this.the_date.value = cal1.getSelectedDates()"; /></td>
        > </form>
        >
        > Of course, when I check the value of "the_date" on the server-side,
        > it's blank.
        >
        > Any help is appreciated. I've been trying to figure this out for the
        > last 6 hours already :(
        >
        > Thanks,
        > Samuel
        Hi Samuel,

        I'm off somewhere and have not time to test, but "this" refers to the
        item the event is
        firing on so this here is the submit-button and not the form? So do
        something like
        "document.getElementById("the_date").value = cal1.getSelectedDates();"
        instead perhaps?

        Best regards,
        Marcus
      • Marcus Engene
        ... Hi, tested it now; i got it to work if i listen to event onclick instead. If you use onsubmit I suppose you must put it on the form tag instead. And then
        Message 3 of 6 , Apr 17, 2006
        • 0 Attachment
          bjames722 wrote:
          > Hi Marcus,
          >
          > Thanks for the quick reply. I tried the following to no avail -
          > "the_date" is still an empty string on the server side :(
          >
          > <td><input type="hidden" id="the_date" name="the_date" />
          > <div id="cal1Container"></div></td>
          >
          > <td><input name="click" type="submit" value="Add Job"
          > onsubmit="document.getElementById('the_date').value =
          > cal1.getSelectedDates();" /></td>
          > </form>
          >
          > Thanks,
          > Samuel
          >
          Hi,

          tested it now; i got it to work if i listen to event onclick instead.
          If you use onsubmit I suppose you must put it on the form tag instead.
          And then "this" would work as expected too, I suppose.

          (Replying to list if someone else will get this problem)

          Best regards,
          Marcus
        • samuel_feynman
          Hi Marcus, Your suggestion worked! THANK YOU!! Here s what I ended up with (in case any newbie in the future needs to do the same thing):
          Message 4 of 6 , Apr 17, 2006
          • 0 Attachment
            Hi Marcus,
            Your suggestion worked! THANK YOU!! Here's what I ended up with (in
            case any newbie in the future needs to do the same thing):

            <form action="/jobs/add" method="POST" name="form"
            onsubmit="this.the_date.value = cal1.getSelectedDates()">
            <input type="hidden" id="the_date" name="the_date" />
            <div id="cal1Container"></div>
            </form>

            Another Q - I didn't see anything in the docs about formatting the
            date. The date currently returns as "Wed Apr 19 2006 00:00:00 GMT-0400
            (Eastern Daylight Time)" and I'm wondering if there is a "format date"
            option to get it into "YYYY-MM-DD" format?

            All the best,
            Samuel

            --- In ydn-javascript@yahoogroups.com, Marcus Engene <ehsmeng@...> wrote:
            >
            > bjames722 wrote:
            > > Hi Marcus,
            > >
            > > Thanks for the quick reply. I tried the following to no avail -
            > > "the_date" is still an empty string on the server side :(
            > >
            > > <td><input type="hidden" id="the_date" name="the_date" />
            > > <div id="cal1Container"></div></td>
            > >
            > > <td><input name="click" type="submit" value="Add Job"
            > > onsubmit="document.getElementById('the_date').value =
            > > cal1.getSelectedDates();" /></td>
            > > </form>
            > >
            > > Thanks,
            > > Samuel
            > >
            > Hi,
            >
            > tested it now; i got it to work if i listen to event onclick instead.
            > If you use onsubmit I suppose you must put it on the form tag instead.
            > And then "this" would work as expected too, I suppose.
            >
            > (Replying to list if someone else will get this problem)
            >
            > Best regards,
            > Marcus
            >
          • Ken Robinson
            ... Actually, it returns an array of objects of type Date. I use the following function which returns the format mm/dd/yyyy. It shouldn t be hard to change it
            Message 5 of 6 , Apr 17, 2006
            • 0 Attachment
              At 10:44 AM 4/17/2006, samuel_feynman wrote (in part):

              >Another Q - I didn't see anything in the docs about formatting the
              >date. The date currently returns as "Wed Apr 19 2006 00:00:00 GMT-0400
              >(Eastern Daylight Time)" and I'm wondering if there is a "format date"
              >option to get it into "YYYY-MM-DD" format?

              Actually, it returns an array of objects of type Date.

              I use the following function which returns the format mm/dd/yyyy. It
              shouldn't be hard to change it to return the format you want.

              Date.prototype.defaultView=function(){
              var dd=this.getDate();
              if(dd<10)dd='0'+dd;
              var mm=this.getMonth()+1;
              if(mm<10)mm='0'+mm;
              var yyyy=this.getFullYear();
              return String(mm+"\/"+dd+"\/"+yyyy)
              }

              I invoke it with:

              var dt = this.getSelectedDates();
              alert('Cell selected:' + dt[0].defaultView()) ;

              Ken
            • Cecil Vermule
              Since you are using a hidden to hold the value, you either need to use that as a Date object on the server side, or in your setDate() function you need to
              Message 6 of 6 , Apr 17, 2006
              • 0 Attachment
                Since you are using a hidden to hold the value, you either need to use that as a Date object on the server side, or in your setDate() function you need to parse it out yourself.
                 
                Example:

                   function setDate()
                   {
                    var lDate = sCalendar.getSelectedDates()[0];

                    selDate.value= lDate.getFullYear() + "-" + lDate.getMonth() + "-" + lDate.getDate();

                    sCalendar.hide();
                   }



                 
                On 4/17/06, samuel_feynman <samuel_feynman@...> wrote:
                Hi Marcus,
                Your suggestion worked! THANK YOU!! Here's what I ended up with (in
                case any newbie in the future needs to do the same thing):

                <form action="/jobs/add" method="POST" name="form"
                onsubmit="this.the_date.value = cal1.getSelectedDates()">
                <input type="hidden" id="the_date" name="the_date" />
                <div id="cal1Container"></div>
                </form>

                Another Q - I didn't see anything in the docs about formatting the
                date. The date currently returns as "Wed Apr 19 2006 00:00:00 GMT-0400
                (Eastern Daylight Time)" and I'm wondering if there is a "format date"
                option to get it into "YYYY-MM-DD" format?

                All the best,
                Samuel

                --- In ydn-javascript@yahoogroups.com, Marcus Engene <ehsmeng@...> wrote:
                >
                > bjames722 wrote:
                > > Hi Marcus,
                > >
                > > Thanks for the quick reply. I tried the following to no avail -
                > > "the_date" is still an empty string on the server side :(
                > >
                > > <td><input type="hidden" id="the_date" name="the_date" />
                > > <div id="cal1Container"></div></td>
                > >
                > > <td><input name="click" type="submit" value="Add Job"
                > > onsubmit="document.getElementById('the_date').value =
                > > cal1.getSelectedDates ();" /></td>
                > > </form>
                > >
                > > Thanks,
                > > Samuel
                > >
                > Hi,
                >
                > tested it now; i got it to work if i listen to event onclick instead.
                > If you use onsubmit I suppose you must put it on the form tag instead.
                > And then "this" would work as expected too, I suppose.
                >
                > (Replying to list if someone else will get this problem)
                >
                > Best regards,
                > Marcus
                >








                Yahoo! Groups Links

                <*> To visit your group on the web, go to:
                   http://groups.yahoo.com/group/ydn-javascript/

                <*> To unsubscribe from this group, send an email to:
                   ydn-javascript-unsubscribe@yahoogroups.com

                <*> Your use of Yahoo! Groups is subject to:
                   http://docs.yahoo.com/info/terms/




              Your message has been successfully submitted and would be delivered to recipients shortly.