
bulrush
Members-
Posts
185 -
Joined
-
Last visited
Never
Everything posted by bulrush
-
Ok, so if there's an error in the Javascript, the Javascript won't run? Is that the problem? Because I put an alert() in my function valDate() and that alert didn't even show up.
-
This code works on my simpler screens. But it doesn't work on my entry screen. My entry screen has 10 identical rows, and one field of each row is a date field, and I'm using an array of date input fields (text boxes). Here is my Javascript first: <script type="text/javascript"> function valDate(fieldObj) { var arr=new Array(); var dt=new Date(); arr=fieldObj.split('/'); if (arr.length<3) //If missing year... { fieldObj.value.='/'.toString(d.GetFullYear()); //Append current year } return fieldObj; } //valDate </script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script type="text/javascript"> //Javascript Comment $(document).ready(function() { var dt=new Date(); $("#txtDate[]").datepicker(); $("#txtDate[]").datepicker( "option", "minDate", new Date(2009, 1-1, 1) ); $("#txtDate[]").datepicker( "option", "maxDate", new Date(2010, 5-1, 31) ); }); </script> Now here is the PHP where I construct the input boxes. Take a look at txtDate[]. <?php $shownrows=0; for ($x=1; $x<=MAXMILERECS; $x++) { $shownrows++; $s='<tr>'; echo $s; $s='<td><input type="text" name="txtMid[]" value="" size="5" readonly />'; echo "$s\n"; $s='<td><input type="text" name="txtDate[]" id="txtDate[]" '. 'value="" size="8" onblur="valDate(this)" />'; //$s.='<div type="text" id="datepicker"></div>'; echo "$s\n"; $s='<td><input type="text" name="txtMiles[]" value="" size="6" />'; echo "$s\n"; $s='<td><input type="text" name="txtNote[]" value="" size="80" />'; echo "$s\n"; $s='</tr>'."\n"; echo "$s\n"; } echo '</table>'."\n"; // End parts. echo $buttons; //Command buttons ?> If the user enters "5/1" as the date, I want to append a slash and the current year. But my function valDate does not appear to be called. Any ideas? Does JS even work with an array of text input boxes?
-
Thank you, this is much appreciated. It would have taken me a good hour to research this and put it together, especially the February valid day part.
-
Yes, that's one of my main references, along with php.net. Both had no examples about dates. They just list the types of text boxes are availabled. I thought <input type="date"> would do something, but it didn't do anything. Their examples are pretty sparse. Even for common business cases (validating input, etc.) And their tutorials are extremely basic.
-
how to set multiple calendars which pop up when editing
bulrush replied to jasonc's topic in Javascript Help
I just learned how to do this yesterday. Here's my code which uses the publicly available Jquery calendar control. In the <head> section of your html doc put this: <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> //Javascript Comment $(document).ready(function() { $("#txtStartdate").datepicker(); //$("#txtStartdate").datepicker( "option", "showOn", 'both' ); $("#txtStartdate").datepicker( "option", "minDate", new Date(2009, 1-1, 1) ); $("#txtStartdate").datepicker( "option", "maxDate", new Date(2010, 5-1, 31) ); $("#txtEnddate").datepicker(); //$("#txtEnddate").datepicker( "option", "showOn", 'both' ); $("#txtEnddate").datepicker( "option", "minDate", new Date(2009, 1-1, 1) ); $("#txtEnddate").datepicker( "option", "maxDate", new Date(2010, 5-1, 31) ); }); </script> In the body of the document call out the date pickers like this: <form action="<?php echo 'editmileage.php?'.SID; ?>" method="post"> <table> <tr><td><label for="txtStartdate">Enter Start Date</label> <td><input type="text" name="txtStartdate" id="txtStartdate" required /> <div type="text" id="datepicker"></div> <tr><td><label>Enter End Date</label> <td><input type="text" name="txtEnddate" id="txtEnddate" required /> <div type="text" id="datepicker"></div> </table> <p> <p>Commands: <input type="submit" name="submit" value="Edit" /> </form> Note the following: The date picker code in the <head> area links to the id attribute of the <input> box, not the name attribute. I set the minDate and maxDate for each control, just to test those properties. By default, the calendar drops down when the user enters the text box, it is not "show always". Your page links to the control online, so if the ajax.googleapis.com site is down, you are SOL (out of luck). Your calendar won't work. You do not need to validate dates picked via the control because the control only shows valid dates within the range minDate to maxDate. But you will need to validate if the user types in a date manually. -
Since Win XP, each Windows XP computer has a unique machine ID, which is how Microsoft prevents Windows from being installed on more than one machine concurrently. This is available via Windows OS API calls, but I don't know more than that. If you can find out the API call, and call it via Javascript, you got your ID. This machine ID is based on a combination of the OS key, and hardware components, to virtually guarentee a unique id for each machine.
-
I have an <input type="text"> field. When the user exits the field I would like to validate the field, which is a date field. I'm sure I need to use Javascript to do this but I am new to Javascript and don't know how to integrate it with html. So, for example, if the user enters "5/16" I want to add the current year "/2010" to make "5/16/2010". This field also has a date picker, but if they don't use the date picker I want to validate what they do enter. Can someone possibly help me? Is there a good site on field validation using Javascript I could read? Thanks.
-
I took your advice and the date picker limited dates like it should. Thanks for your help. I admit I am quite new at this online programming. It's like learning 5 new languages just to get the job done: HTML, SQL, PHP, Javascript and CSS. Usually I only have to learn 1 new language at a time.
-
The docs here say the dates can be a string: http://keith-wood.name/datepickRef.html Unless different versions of the Jquery datepicker work differently.
-
Ok, so I made some changes and the basic date picker worked. Now I want to restrict dates the user can enter. They can only enter dates in the past, up to today's date. So I set my minDate and maxDate like below. <head> <script> $(document).ready(function() { $("#txtEnddate").datepicker(); $("#txtEnddate").datepicker( "option", "showOn", 'both' ); $("#txtEnddate").datepicker({minDate: '01/01/2009'}); $("#txtEnddate").datepicker({maxDate: '06/01/2010'}); }); </script> </head> However the date picker still lets me pick dates after 6/1/2010. What am I doing wrong?
-
Well, that worked! Thank you. Since txtEnddate is now tied to the date picker, I really don't need this option, do I? $( "#txtEnddate" ).datepicker( "option", "altField", 'txtEnddate' );
-
I forgot to mention I'm using Firefox 3.6 and Javascript is enabled.
-
Please be patient, I am new to Javascript. I'm having trouble getting the Jquery date picker to work. Here is a link to the page: http://www.ignitionworkshop.com/toolbox/training/mileage/zztest.php I got my information from here: http://docs.jquery.com/UI/Datepicker First, I wanted the date picker to drop down only when the field has focus. Next, when the user picks a date, I want the date copied to the input field called "txtEnddate". Here is my html code. I tried to simplify it. The date picker appears, but when I click it, the date is not copied to txtEnddate. Also, the date picker does not drop down, it is always on the screen. <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test Form</title> <link rel="stylesheet" type="text/css" href="style.css" /> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> $(document).ready(function() { $("#datepicker").datepicker(); }); $( ".selector" ).datepicker( "option", "altField", 'txtEnddate' ); $( ".selector" ).datepicker( "option", "showOn", 'both' ); </script> </head> <body> <h2>Test Input Date/Time pickers, v.10a</h2> <!-- comment --> <form action="<?php echo $_SERVER['PHP_SELF'].'?'.SID; ?>" method="post"> <table> <tr><td valign="top">Date picker <td><input type="text" name="txtEnddate" id="txtEnddate" /> <div type="text" id="datepicker"></div> </table> <p> <p>Commands: <input type="submit" name="submit" value="Save" /> </form> <noscript> <h3>You must have Javascript enabled in order to use this application. Please enabled Javascript for your browser. </h3> </noscript> </body> </html>
-
In other words I have to use a PHP function which does the brute force method, or perhaps uses a regex? I can't use the pattern attribute? Well, I can't see how the pattern="" attribute would display an error message.
-
How do I do this with Javascript?
-
I noticed there is an <INPUT> type of 'date'. Is this a date picker? If not, how do I implement a date picker? Do I have to get into some Javascript? Are there any free date picker controls out there? References and examples seem to be few and far between. Thanks.
-
If I have a text box for user input like this: $s='<td><input type="hidden" name="txtMID[]" value="'.$row['mid'].'" size="6" />'; echo "$s\n"; How do I allow only certain characters, like letters (upper and lower case) and digits? How do I allow some characters like ampersand, at sign, dollar sign, question mark? Thanks.
-
I would like to execute a SELECT statement where my field "mdate" (a DATE type field) is greater than or equal to the date the user entered, which is stored as a string in $startdate. I still don't understand how to compare DATE type fields. Is a DATE type field stored as a string, or stored as an integer and displayed automatically as a string in the YYYY-MM-DD format? Here is what I have that doens't work. $query = "SELECT mdate, miles, username, note, payrate, printdate ". "FROM mileage ". "WHERE (username='".$username."') ". "AND (mdate BEWEEN '$startdate' AND NOW()) ". "AND (printdate IS NULL) ". "ORDER BY mdate ". ";"; Thank you.
-
Thank you, Ken. That worked.
-
I have a variable where the user types in a date, like "5/10/2010". I want to store this in a Mysql field that is a DATE type. How do I convert it? When I tried storing the date as a string, the field just contains the default value which is '00-00-0000'. When I tried to convert the date like this: $q="INSERT INTO table (mdate) VALUES ('".strtotime($datevar)."')"; Mysql still stores the default value of '00-00-0000'. The documentation on 2 sites wasn't clear how to make this happen. Thanks.
-
I see the problem now, I should only use SET once. not multiple times.
-
Here is my table layout. CREATE TABLE `hgroup` ( `grid` bigint(20) NOT NULL auto_increment, `createuser` varchar(15) NOT NULL default '', `createdate` datetime NOT NULL default '0000-00-00 00:00:00', `updateuser` varchar(15) default NULL, `updatedate` datetime default NULL, `groupname` varchar(80) NOT NULL default '', `image1` varchar(30) default NULL, `classcode` char(3) default NULL, `sin` varchar(30) default NULL, `openmkt` tinyint(1) NOT NULL default '0', `col1name` varchar(50) default NULL, `basemodel` varchar(50) default NULL, PRIMARY KEY (`grid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=33 ; When I reduce my query down to this: UPDATE hgroup SET groupname='aaTest 1 edited again', SET basemodel='AZA' WHERE grid=30; I start getting errors. That means, the field 'basemodel' is giving me errors somehow.
-
Sorry. I modified some of the things. Here is the real SQL statement. UPDATE hgroup SET groupname='aaTest 2 group edited', SET basemodel='abh', SET classcode='', SET sin='', SET openmkt=0, SET updateuser='chuckr', SET updatedate=NOW() WHERE grid=28; I ran it through the phpMyAdmin sql processor, and it gave me an error, but everything looked ok. Here is the phpMyadmin sql error: SQL query: UPDATE hgroup SET groupname = 'aaTest 2 group edited', SET basemodel = 'abh', SET classcode = '', SET sin = '', SET openmkt =0, SET updateuser = 'chuckr', SET updatedate = NOW( ) WHERE grid =28 MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET basemodel='abh', SET classcode='', SET sin='', SET openmkt=0, SET updateuser' at line 1 Oddly enough, all these fields work fine in an INSERT and SELECT statement. So it shouldn't be a problem with the field names, right?
-
I'm just not seeing an error in this SQL statement. Can anyone help me please? UPDATE group SET groupname='aaTest 2 group edited', SET basemodel='abh', SET classcode='', SET sin='', SET openmkt=0, SET updateuser='foo', SET updatedate=NOW() WHERE gid=28; But php returns an error when I use this code: if (!$result=mysqli_query($dbc,$query))