12 Replies Latest reply on Jun 10, 2009 3:55 AM by glennyboy1

    send multiple ids to single text field via dropdowns

    glennyboy1

      Hi

       

      This is driving me crazy.

       

      I have x3 dropdowns 'Day' 'Month' 'Year' and I want to send those selections to a single filed marked with id 'date' to make up a correct date syntax without refreshing or submitting the form. I've been using getelementbyid to send the dropdown request onchange="getAmount(this.id)", but it only sends one id and when the next drop-down is selected it replaces the previous selection, rather than putting them all together in correct date format.

       

      Here is the code I am using, but it is obviosuly flawed:-

       

      On each dropdown:-

       

      getAmount(this.id)

       

      and then the following javascript to send the ids

       

      <script type="text/javascript">

      function getAmount(optText)

      {

      var sel = document.getElementById(optText);

      document.getElementById("date","['EventDayID_<?php echo $cnt1; ?>','EventMonthID_<?php echo $cnt1; ?>','EventYearID_<?php echo $cnt1; ?>']").value = sel.getElementsByTagName("option")[sel.selectedIndex].innerHTML;

      }

      </script>

       

      and the input field that I want to capture the full date:-

       

      <input type="text" name="date" id="date" />

       

      Does anyine know how to handle this?

       

      Many Thanks

       

      Glennyboy

        • 1. Re: send multiple ids to single text field via dropdowns
          zzipper7 Level 1

          I'm a little confused on the intent of the date. I feel they may be a simpler way if I knew exactly what you were doing.

           

          What I mean is you are "collecting" the three fields for a syntax issue...but there are other places to intercept those values and convert them with php rather than Javascript.

           

          Can you give me a better description of the use and flow? I can send back some possible solutions but I need to know what the user sees vs. what you want to accomplish.

           

           

           

           

          Thanks,

          J

          • 2. Re: send multiple ids to single text field via dropdowns
            glennyboy1 Level 1

            Hi J

             

            Thanks for your initial speedy response!

             

            OK so I am creating a multiple use events calendar and the primary use of this is to create a nested repeat as follows:-

             

            YearID     (from DB)

            MonthID   (from DB) 

            DayID      (from DB)

             

            So an example woudd be:-

             

            2009

             

            January

            20th January - Event Name + other fields

            24th January - Event Name + other fields

             

            February

            20th February - Event Name + other fields

            24th February - Event Name + other fields

             

            March

             

            20th March - Event Name + other fields

            24th March - Event Name + other fields

             

            and so on

             

            The main reason my primary interface for doing this was not just a date picker was that I couldn't then figure out how to then create a nested repeat with just a single date field and not parent and child IDs and also be able to select through years on a horizontal looper on the actual events page:-

             

            2009, 2010, 2011, 2012, 2013 etc

             

            2009

             

            January

            20th January - Event Name + other fields

            24th January - Event Name + other fields

             

            February

             

            20th February - Event Name + other fields

            24th February - Event Name + other fields

             

             

             

            again I thought the best way to do this would be via YearID, but if there is a way of just using a date picker for date and achieving the same result as above then I would definately go for that.

             

            Now the reason I want (or think I want) to store the correct formatted date form YearID, MonthID, DayID as well in the DB is that I also want to use the correctly formatted date in other ares of the site and as far as I can see the most robust method is not to use split up date values. So in my dynamic form I want to capture the drop down selections of Year, Month, Day and pass them to Date (currently a test text field, but eventually a hidden field and also ultimately EventDate in my DB). Again if this can be achieved with just date pickers (and not split up drop-downs) then that would obviously be much better.

             

            I've attached a copy of the edit_events.php dynamic form page. Ultimately I guess some of the fields I'm using for testing will be erroneous, depending on how it works best.

             

            Look forward to your resposne.

             

            Cheers

             

            Glennyboy

             

             

            • 3. Re: send multiple ids to single text field via dropdowns
              glennyboy1 Level 1

              Hi J

               

              Thanks for your initial speedy response!

               

              OK so I am creating a multiple use events calendar and the primary use of this is to create a nested repeat as follows:-

               

              YearID     (from DB)

              MonthID   (from DB)

              DayID      (from DB)

               

              So an example woudd be:-

               

              2009

               

              January

              20th January - Event Name + other fields

              24th January - Event Name + other fields

               

              February

               

              20th February - Event Name + other fields

              24th February - Event Name + other fields

               

              March

               

               

              20th March - Event Name + other fields

              24th March - Event Name + other fields

               

               

              and so on

               

              The main reason my primary interface for doing this was not just a date picker was that I couldn't then figure out how to then create a nested repeat with just a single date field and not parent and child IDs and also be able to select through years on a horizontal looper on the actual events page:-

               

              2009, 2010, 2011, 2012, 2013 etc

               

              2009

               

              January

              20th January - Event Name + other fields

              24th January - Event Name + other fields

               

              February

               

              20th February - Event Name + other fields

              24th February - Event Name + other fields

               

              again I thought the best way to do this would be via YearID, but if there is a way of just using a date picker for date and achieving the same result as above then I would definately go for that.

               

              Now the reason I want (or think I want) to store the correct formatted date form YearID, MonthID, DayID as well in the DB is that I also want to use the correctly formatted date in other ares of the site and as far as I can see the most robust method is not to use split up date values. So in my dynamic form I want to capture the drop down selections of Year, Month, Day and pass them to Date (currently a test text field, but eventually a hidden field and also ultimately EventDate in my DB). Again if this can be achieved with just date pickers (and not split up drop-downs) then that would obviously be much better.

               

              I've attached a copy of the edit_events.php (as .htm as php ext is not allowed for some reason) dynamic form page. Ultimately I guess some of the fields I'm using for testing will be erroneous, depending on how it works best.

               

              Look forward to your response.

               

              Cheers

               

              Glennyboy

              • 4. Re: send multiple ids to single text field via dropdowns
                zzipper7 Level 1

                Ok, So just to be clear because there a few ways to come at this.

                 

                The date picker used by the user, picks one date....but the value that needs to go to the DB should have a list of dates, from somewhere, added to that value and inserted to the DB.

                 

                The user picks 2009...the value that goes to the db is  2009, 2011, 2013. 

                 

                Is this the issue?

                 

                I'm having trouble envisioning the reason for the multiple dates, where they come from (auto created or db recordset)and how they be used again.  Its important because separating them later can be a booger.

                     Grouping multiple values for input is simple

                     Changing the syntax before input is simple

                     Having each date be an identifier or unique value later  not as simple

                 

                 

                Going back to your original post:

                "....a single filed marked with id 'date' to make up a correct date syntax"..... 

                 

                Your "inset record syntax looks like this in ADDT: its naming the column and the field to get the data from.

                   $userRegistration->addColumn("date_sql_col", "STRING_TYPE", "POST", "date", "date_feild_name");

                    

                Set a new variable at the top of the page to reconstruct your date fields for use in the statement above

                Change the syntax with the "Y-m-d" string:

                          $my date = date("Y-m-d",mktime(0, 0, 0, $_POST['day'],$_POST['day'], $_POST['year']));  will echo "2009-05-11" syntax based on your field values

                 

                Then add month or years with 1  Y-m-d",mktime(0, 0, 0, $_POST['day'],$_POST['day']1, $_POST['year']+1) 

                 

                Do several to increment the years

                $mydate  = date(Y-m-d",mktime(0, 0, 0, $_POST['month'],$_POST['day'], $_POST['year']+1))     =2010

                $mydate2 = date(Y-m-d",mktime(0, 0, 0, $_POST['month'],$_POST['day'], $_POST['year']+2))    =2011

                $mydate3 = date(Y-m-d",mktime(0, 0, 0, $_POST['month'],$_POST['day'], $_POST['year']+3))   =2012

                 

                Then group your vars to insert: 

                 

                $userRegistration->addColumn("date_sql_col", "STRING_TYPE", "level", $mydate .', '. $mydate2  .', '. $mydate3 );

                will insert 2009-05-11, 2010-05-11, 20011-05-11

                 

                You can do the same for just the post values:

                 

                $userRegistration->addColumn("date_sql_col", "STRING_TYPE", "level", $_POST['month'] .', '. $_POST['day'] .', '. $_POST['year']);

                will insert 2009-05-11

                 

                These are general solutions for producing the date and inserting them,  I hope its some kind of help.

                       *There is no need to refresh because the code is doing the work on submit..the user just sees their entered field data.

                     *If they need to see the new dates before entering, then we are back to JavaScript.

                 

                If these are the right solution but don't work right, my syntax may be off a little and I can check it against a live db for you.

                 

                If these are not what you were looking for please clarify the use.

                 

                 

                Thanks,

                J

                • 5. Re: send multiple ids to single text field via dropdowns
                  glennyboy1 Level 1

                  Hi J

                   

                  I might be wrong )so apologies if I am not following fully), but I envisage possible issues here:-

                   

                  1. In my current model my date does need to be an identifier (with primary key being YearID) - this so the actual data can be manipulated as recordset in horizontal looper as shown earlier and also so that additional dates can easily be added in later.

                  2. Day, Month, Year values are initially pulled from the DB, but in your example it appears that to increment the years each needs to be inserted manually?

                   

                  I think really the crux of this would be if it is in fact possible to have a date picker (actually x2 Date & DateTo) that outputs the full date dd/mm/yyyy and then for that date to be used in a recordset that outputs the date entries in my desired format:-

                   

                  ---------------

                  Select Date     2009, 2010, 2011 >

                   

                  2009

                  January

                   

                  12-13 Event Name (2 day event)

                  13 Event Name

                   

                  February

                   

                  15 -17 Event Name (3 day event)

                  17 Event Name

                   

                  etc.

                   

                  ----------------

                   

                  If this is possible then I can do away with the fields for YearID, MonthID, DayID completely and just use a single date input - as per eralier this actually would be a more preferable model, but I just couldn't work it out.

                   

                  Does this make sense?

                   

                  Cheers

                   

                  Glennyboy

                  • 6. Re: send multiple ids to single text field via dropdowns
                    zzipper7 Level 1

                    Ok...so you need "to" and "from" dates to pull a record set. (you may have complicated it by giving the dates an ID....unless you are pulling multiple ids for the date...still over complicating it... it think)

                     

                    Things we know:

                    *The date picker picks one date at a time:  Do we want to set a following date automaticlty(forced value) or let the user do it?

                    *the date picker allows for formatting - no big deal to make the second date by the user or a forced value

                    • not sure why the date as to bea unique value becayuse we can search by date but if you have a unique ID for each date, that works too.

                    *then we have the user click  "go" or "submit" and the recorset apeears.

                     

                    Is this what we are after? Very simple

                     

                     

                    Note: Javascript on the page after its loaded will not pull a record set...you would need to pull ALL records in a JS array to get those results w/o a refresh...thats not my best skillset.

                     

                    If I've got your big picture here let me know and I'll send it to you. Sorry for the back and forth.

                     

                    Can you use php admin and eport a copyo the DB table and resned the page....I could fix it pretty easily I believe.

                    1 person found this helpful
                    • 7. Re: send multiple ids to single text field via dropdowns
                      glennyboy1 Level 1

                      Hi

                       

                      Not sure what I have done to deserve this but I can't start new topics:-

                       

                      "It appears you're not allowed to view what you requested. You might contact your administrator if you think this is a mistake."

                       

                      So I'm going to continue in this thread (while I work out how to contact Adobe, or they realise their is an error) as my question still relates to date formats/regions.

                       

                      Basically I want to show a div 'divider' if the date is greater than or equal to the curdate() in my repeat region.

                       

                      So here is my code:-

                       

                      <?php

                      // Show IF Conditional region1

                      if (@$row_RsEvents['EventDate'] >= "curdate()") {

                      ?>

                          <div class="divider"></div>

                          <?php }

                      // endif Conditional region1

                      ?>

                       

                      It seems that it's viewing curdate() as a text string in the conditional region, rather than as the proper current date curdate().

                       

                      Can anyone advise how to do this please.

                       

                      Thanks

                       

                      Glennyboy

                      • 8. Re: send multiple ids to single text field via dropdowns
                        zzipper7 Level 1

                        = date('Y-m-d")) { ?>

                        Some Text Here

                         

                        Thanks,

                        J

                        • 9. Re: send multiple ids to single text field via dropdowns
                          glennyboy1 Level 1

                          Hi Buddy

                           

                          Think there was a synatx error there somewhere J, but it did put me in the right direction:-

                           

                           

                          <?php

                          // Show IF Conditional region1

                          if (@$row_RsEvents['EventDate'] >= date("curdate()")) {

                          ?>

                              <div class="divider"></div>

                              <?php }

                          // endif Conditional region1

                          ?>

                           

                          Works well!

                           

                          Cheers

                           

                          Glennyboy

                          • 10. Re: don't show previously selected check box row in many-to-many nested repeat
                            glennyboy1 Level 1

                            Still can't add a new thread so I'm carrying this one on as again it still relates to my event's app.

                             

                            I now need to create a conditional region whereby a many-to-many checkbox is not shown if the user has previously selected it. This is to stop them from selecting it again, or thinking they hadn't selected it earlier. So basically where my code currently outputs a nested repeat with items selected previosuly being ticked/checked I simply want to hide those items, showing only those that have not been selected/checked:-

                             

                            <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">

                                <table cellpadding="0" cellspacing="0">

                             

                              <tr>

                                <td>

                                  <?php

                            // Show IF Conditional region1

                            if (something == "something") {

                            ?>

                                    <table width="350" border="0" class="KT_mtm">

                                        <tr>

                            <?php

                              $cnt1 = 0;

                            ?>

                            <?php

                              if ($totalRows_rsvisitors>0) {

                                $nested_query_rsevents = str_replace("123456789", $row_rsvisitors['VisitorID'], $query_rsevents);

                                mysql_select_db($database_db);

                                $rsevents = mysql_query($nested_query_rsevents, $db) or die(mysql_error());

                                $row_rsevents = mysql_fetch_assoc($rsevents);

                                $totalRows_rsevents = mysql_num_rows($rsevents);

                                $nested_sw = false;

                                if (isset($row_rsevents) && is_array($row_rsevents)) {

                                  do { //Nested repeat

                            ?>

                             

                                            <td width="35" height="38" valign="top">

                                              <input id="mtm_<?php echo $row_rsevents['EventID']; ?>" name="mtm_<?php echo $row_rsevents['EventID']; ?>" type="checkbox" value="1" <?php if ($row_rsevents['EventMtmVisitorID'] != "") {?> checked<?php }?> /> </td>

                                            <td width="305">

                                              <label for="mtm_<?php echo $row_rsevents['EventID']; ?>"><?php echo $row_rsevents['EventName']; ?><span id="date"><?php echo date('l, d/M/Y g:i A',strtotime($row_rsevents['EventDate'])); ?></span></label> </td>

                                            <?php

                            $cnt1++;

                            if ($cnt1%1 == 0) {

                            echo "</tr><tr>";

                            }

                            ?>

                                              <?php

                                  } while ($row_rsevents = mysql_fetch_assoc($rsevents)); //Nested move next

                                }

                              }

                            ?>

                                        </tr>

                                      </table>

                                    <?php }

                            // endif Conditional region1

                            ?></td>

                              </tr>

                              <tr>

                                <td><input name="KT_Update1" type="submit" class="button" id="KT_Update1" value="Register to selected events" /></td>

                              </tr>

                                </table>

                                <input type="hidden" name="VisitorID" id="VisitorID" value="<?php echo KT_escapeAttribute($row_rsvisitors['VisitorID']); ?>" />

                                </form>

                             

                            All guidance greatly appreciated!

                             

                            Glennyboy

                            • 11. Re: send multiple ids to single text field via dropdowns
                              zzipper7 Level 1

                              You only need an identifier of some kind...

                               

                               

                              Change your Mysql to loose or add check boxes used or unused:

                               

                              SELECT * FROM table  WHERE column  IS NULL   or  IS NOT NULL

                              You can expand  

                              SELECT * FROM table  WHERE column1  = something   AND column2 IS NOT NULL

                               

                              or

                               

                                you check each checkbox before you print it,  if (cb1!=""  or    cb1=="") {  echo/print/do something;}

                               

                               

                              Thanks,

                              J

                              • 12. Re: send multiple ids to single text field via dropdowns
                                glennyboy1 Level 1

                                Nice on J.

                                 

                                Was as simple as adding 'AND EventMtmVisitorID IS NULL' in my recordset WHERE clause.

                                 

                                Cheers

                                 

                                Glennyboy