xox Posted May 19, 2011 Share Posted May 19, 2011 Hello, I'm using date picker for my input boxes that needs date as input, everything works ok on an simple example like this css+js <style type="text/css"> @import "kolendar_stil.css"; </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="kolendar.js"></script> <script type="text/javascript"> $(function() { $('#popupDatepicker').datepick(); $('#inlineDatepicker').datepick({onSelect: showDate}); }); function showDate(date) { alert('The date chosen is ' + date); } </script> input (ISSUE only first textbox get's calender) <p>a <input type="text" id="popupDatepicker"></p> <p>b <input type="text" id="popupDatepicker"></p> <p>c <input type="text" id="popupDatepicker"></p> This was just an example, here is my code of what I'm trying <?php if($row['fieldtype'] == 'a') { $date++; ?> <style type="text/css"> @import "kolendar_stil.css"; </style> <script type="text/javascript"> $(function() { $('#date').datepick(); }); </script> <input class="textFieldXXL" type="text" name="textboxZamenjava[]" id="date<?php echo $date;?>" maxlength="50" value="" /> <img class="eFormsHelp" src="help.jpg" id="pomoc<?php echo $stej;?>" /> <LABEL class="inputDescription" FOR="desc"><?php echo $row['description'];?></LABEL> <div class="eFormsError"> <div id=divDate<?php echo $date;?>> </div> </div> But JS date picker won't show up, what' could be the issue? Here's the source of whole script, but I think there is no issue http://pastebin.com/RfgtkUzs Quote Link to comment https://forums.phpfreaks.com/topic/236908-problems-with-date-picker-and-multiple-inputs/ Share on other sites More sharing options...
xox Posted May 21, 2011 Author Share Posted May 21, 2011 NoOne? Quote Link to comment https://forums.phpfreaks.com/topic/236908-problems-with-date-picker-and-multiple-inputs/#findComment-1218383 Share on other sites More sharing options...
dadamssg87 Posted May 22, 2011 Share Posted May 22, 2011 <style type="text/css"> @import "kolendar_stil.css"; </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript" src="kolendar.js"></script> <script type="text/javascript"> $(function() { $('#popupDatepicker1').datepick(); $('#inlineDatepicker').datepick({onSelect: showDate}); }); $(function() { $('#popupDatepicker2').datepick(); $('#inlineDatepicker').datepick({onSelect: showDate}); }); $(function() { $('#popupDatepicker3').datepick(); $('#inlineDatepicker').datepick({onSelect: showDate}); }); function showDate(date) { alert('The date chosen is ' + date); } </script> <p>a <input type="text" id="popupDatepicker1"></p> <p>b <input type="text" id="popupDatepicker2"></p> <p>c <input type="text" id="popupDatepicker3"></p> Quote Link to comment https://forums.phpfreaks.com/topic/236908-problems-with-date-picker-and-multiple-inputs/#findComment-1218579 Share on other sites More sharing options...
dadamssg87 Posted May 22, 2011 Share Posted May 22, 2011 and if that doesn work..this works form me <script> $(function() { $( "#datepicker1" ).datepicker({ autoSize: true, showOtherMonths: true, selectOtherMonths: true }); $( "#datepicker2" ).datepicker({ autoSize: true, showOtherMonths: true, selectOtherMonths: true }); }); </script> <input id='datepicker1' type='text' value='05/21/2011'><br><br> <input id='datepicker2' type='text' value='05/21/2011'> Quote Link to comment https://forums.phpfreaks.com/topic/236908-problems-with-date-picker-and-multiple-inputs/#findComment-1218582 Share on other sites More sharing options...
xox Posted May 24, 2011 Author Share Posted May 24, 2011 Well that's OK if you know how many input boxes you have, but I don't, that's the problem. My script is creating input boxes on the fly, depending on values in database (mysql). An example of my code for date input field <?php if($row['fieldtype'] == 'd') //d as date { $date++; ?> <input class="textFieldXXL" type="text" name="textboxRes[]"[b] id="datum<?php echo $date;?>"[/b] maxlength="50" value="" /> <img class="eFormsHelp" src="date.jpg" id="date<?php echo $count;?>" /> <LABEL class="inputDescription" FOR="desc"><?php echo $row['description'];?></LABEL> <div class="eFormsError"> <div id=divDatum<?php echo $date;?>> </div> </div> <?php } I've bolded where the problem is... Quote Link to comment https://forums.phpfreaks.com/topic/236908-problems-with-date-picker-and-multiple-inputs/#findComment-1219678 Share on other sites More sharing options...
dadamssg87 Posted May 27, 2011 Share Posted May 27, 2011 I was doing something exactly the same. Little different syntax but what you need to do is create all the jquery datepicker functions when you're cycling through your date inputs. Something like the following <?php if($row['fieldtype'] == 'd') //d as date { $date++; ?> <input class="textFieldXXL" type="text" name="textboxRes[]"[b] id="datum<?php echo $date;?>"[/b] maxlength="50" value="" /> <img class="eFormsHelp" src="date.jpg" id="date<?php echo $count;?>" /> <LABEL class="inputDescription" FOR="desc"><?php echo $row['description'];?></LABEL> <div class="eFormsError"> <div id=divDatum<?php echo $date;?>> </div> </div> <script type="text/javascript"> $(function() { $('#datum<?php echo $date;?>').datepick(); $('#inlineDatepicker').datepick({onSelect: showDate}); }); </script> <?php } or you can leave it how you had it. And then put this in the head of your page <html> <head> <script type="text/javascript"> <?php if($row['fieldtype'] == 'd') //d as date { $date++; ?> $(function() { $('#datum<?php echo $date;?>').datepick(); $('#inlineDatepicker').datepick({onSelect: showDate}); }); <?php } ?> </script> </head> you just need to make sure the datepicker functions for each input are displayed when the page loads. Quote Link to comment https://forums.phpfreaks.com/topic/236908-problems-with-date-picker-and-multiple-inputs/#findComment-1221018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.