Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help modifying some code

Status
Not open for further replies.

cheekynorton

Technical User
Jan 21, 2002
12
0
0
GB
Hi this is a free script used to submit dates in a form.
Upon clicking an icon a new window loads containing a calender. By selecting the date required, it is then inserted into the html form as ddmmyyyy then the current time after it.
What i would like is the same process but only the date being inserted not the time.
Can someone tell what part of the scripting needs to be edited to remove the time entry.
Many thanks for all your help!

HTML DOCUMENT

<script language=&quot;JavaScript&quot; src=&quot;ts_picker.js&quot;>

//Script by Denis Gritcyuk: tspicker@yahoo.com
//Submitted to JavaScript Kit (//Visit for this script

</script>

<form name=&quot;tstest&quot;>
<input type=&quot;Text&quot; name=&quot;timestamp&quot; value=&quot;&quot;>
<a href=&quot;javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);&quot;><img src=&quot;cal.gif&quot; width=&quot;16&quot; height=&quot;16&quot; border=&quot;0&quot; alt=&quot;Click Here to Pick up the timestamp&quot;></a>
</form>

JAVASCRIPT FILE

// Title: Timestamp picker
// Description: See the demo at url
// URL: // Script featured on: // Version: 1.0
// Date: 12-05-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
// header lines are left unchanged. Feel free to contact the author
// for feature requests and/or donations

function show_calendar(str_target, str_datetime) {
var arr_months = [&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;,
&quot;July&quot;, &quot;August&quot;, &quot;September&quot;, &quot;October&quot;, &quot;November&quot;, &quot;December&quot;];
var week_days = [&quot;Su&quot;, &quot;Mo&quot;, &quot;Tu&quot;, &quot;We&quot;, &quot;Th&quot;, &quot;Fr&quot;, &quot;Sa&quot;];
var n_weekstart = 1; // day week starts from (normally 0 or 1)

var dt_datetime = (str_datetime == null || str_datetime ==&quot;&quot; ? new Date() : str2dt(str_datetime));
var dt_prev_month = new Date(dt_datetime);
dt_prev_month.setMonth(dt_datetime.getMonth()-1);
var dt_next_month = new Date(dt_datetime);
dt_next_month.setMonth(dt_datetime.getMonth()+1);
var dt_firstday = new Date(dt_datetime);
dt_firstday.setDate(1);
dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
var dt_lastday = new Date(dt_next_month);
dt_lastday.setDate(0);

// html generation (feel free to tune it for your particular application)
// print calendar header
var str_buffer = new String (
&quot;<html>\n&quot;+
&quot;<head>\n&quot;+
&quot; <title>Calendar</title>\n&quot;+
&quot;</head>\n&quot;+
&quot;<body bgcolor=\&quot;White\&quot;>\n&quot;+
&quot;<table class=\&quot;clsOTable\&quot; cellspacing=\&quot;0\&quot; border=\&quot;0\&quot; width=\&quot;100%\&quot;>\n&quot;+
&quot;<tr><td bgcolor=\&quot;#4682B4\&quot;>\n&quot;+
&quot;<table cellspacing=\&quot;1\&quot; cellpadding=\&quot;3\&quot; border=\&quot;0\&quot; width=\&quot;100%\&quot;>\n&quot;+
&quot;<tr>\n <td bgcolor=\&quot;#4682B4\&quot;><a href=\&quot;javascript:window.opener.show_calendar('&quot;+
str_target+&quot;', '&quot;+ dt2dtstr(dt_prev_month)+&quot;'+document.cal.time.value);\&quot;>&quot;+
&quot;<img src=\&quot;prev.gif\&quot; width=\&quot;16\&quot; height=\&quot;16\&quot; border=\&quot;0\&quot;&quot;+
&quot; alt=\&quot;previous month\&quot;></a></td>\n&quot;+
&quot; <td bgcolor=\&quot;#4682B4\&quot; colspan=\&quot;5\&quot;>&quot;+
&quot;<font color=\&quot;white\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;
+arr_months[dt_datetime.getMonth()]+&quot; &quot;+dt_datetime.getFullYear()+&quot;</font></td>\n&quot;+
&quot; <td bgcolor=\&quot;#4682B4\&quot; align=\&quot;right\&quot;><a href=\&quot;javascript:window.opener.show_calendar('&quot;
+str_target+&quot;', '&quot;+dt2dtstr(dt_next_month)+&quot;'+document.cal.time.value);\&quot;>&quot;+
&quot;<img src=\&quot;next.gif\&quot; width=\&quot;16\&quot; height=\&quot;16\&quot; border=\&quot;0\&quot;&quot;+
&quot; alt=\&quot;next month\&quot;></a></td>\n</tr>\n&quot;
);

var dt_current_day = new Date(dt_firstday);
// print weekdays titles
str_buffer += &quot;<tr>\n&quot;;
for (var n=0; n<7; n++)
str_buffer += &quot; <td bgcolor=\&quot;#87CEFA\&quot;>&quot;+
&quot;<font color=\&quot;white\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;+
week_days[(n_weekstart+n)%7]+&quot;</font></td>\n&quot;;
// print calendar table
str_buffer += &quot;</tr>\n&quot;;
while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
dt_current_day.getMonth() == dt_firstday.getMonth()) {
// print row heder
str_buffer += &quot;<tr>\n&quot;;
for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
if (dt_current_day.getDate() == dt_datetime.getDate() &&
dt_current_day.getMonth() == dt_datetime.getMonth())
// print current date
str_buffer += &quot; <td bgcolor=\&quot;#FFB6C1\&quot; align=\&quot;right\&quot;>&quot;;
else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
// weekend days
str_buffer += &quot; <td bgcolor=\&quot;#DBEAF5\&quot; align=\&quot;right\&quot;>&quot;;
else
// print working days of current month
str_buffer += &quot; <td bgcolor=\&quot;white\&quot; align=\&quot;right\&quot;>&quot;;

if (dt_current_day.getMonth() == dt_datetime.getMonth())
// print days of current month
str_buffer += &quot;<a href=\&quot;javascript:window.opener.&quot;+str_target+
&quot;.value='&quot;+dt2dtstr(dt_current_day)+&quot;'+document.cal.time.value; window.close();\&quot;>&quot;+
&quot;<font color=\&quot;black\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;;
else
// print days of other months
str_buffer += &quot;<a href=\&quot;javascript:window.opener.&quot;+str_target+
&quot;.value='&quot;+dt2dtstr(dt_current_day)+&quot;'+document.cal.time.value; window.close();\&quot;>&quot;+
&quot;<font color=\&quot;gray\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;;
str_buffer += dt_current_day.getDate()+&quot;</font></a></td>\n&quot;;
dt_current_day.setDate(dt_current_day.getDate()+1);
}
// print row footer
str_buffer += &quot;</tr>\n&quot;;
}
// print calendar footer
str_buffer +=
&quot;<form name=\&quot;cal\&quot;>\n<tr><td colspan=\&quot;7\&quot; bgcolor=\&quot;#87CEFA\&quot;>&quot;+
&quot;<font color=\&quot;White\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;+
&quot;Time: <input type=\&quot;text\&quot; name=\&quot;time\&quot; value=\&quot;&quot;+dt2tmstr(dt_datetime)+
&quot;\&quot; size=\&quot;8\&quot; maxlength=\&quot;8\&quot;></font></td></tr>\n</form>\n&quot; +
&quot;</table>\n&quot; +
&quot;</tr>\n</td>\n</table>\n&quot; +
&quot;</body>\n&quot; +
&quot;</html>\n&quot;;

var vWinCal = window.open(&quot;&quot;, &quot;Calendar&quot;,
&quot;width=200,height=250,status=no,resizable=yes,top=200,left=200&quot;);
vWinCal.opener = self;
var calc_doc = vWinCal.document;
calc_doc.write (str_buffer);
calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
var re_date = /^(\d+)\-(\d+)\-(\d+)\s+(\d+)\:(\d+)\:(\d+)$/;
if (!re_date.exec(str_datetime))
return alert(&quot;Invalid Datetime format: &quot;+ str_datetime);
return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}
function dt2dtstr (dt_datetime) {
return (new String (
dt_datetime.getDate()+&quot;-&quot;+(dt_datetime.getMonth()+1)+&quot;-&quot;+dt_datetime.getFullYear()+&quot; &quot;));
}
function dt2tmstr (dt_datetime) {
return (new String (
dt_datetime.getHours()+&quot;:&quot;+dt_datetime.getMinutes()+&quot;:&quot;+dt_datetime.getSeconds()));
}
 
Here is the change


// Title: Timestamp picker
// Description: See the demo at url
// URL: // Script featured on: // Version: 1.0
// Date: 12-05-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
// header lines are left unchanged. Feel free to contact the author
// for feature requests and/or donations

function show_calendar(str_target, str_datetime) {
var arr_months = [&quot;January&quot;, &quot;February&quot;, &quot;March&quot;, &quot;April&quot;, &quot;May&quot;, &quot;June&quot;,
&quot;July&quot;, &quot;August&quot;, &quot;September&quot;, &quot;October&quot;, &quot;November&quot;, &quot;December&quot;];
var week_days = [&quot;Su&quot;, &quot;Mo&quot;, &quot;Tu&quot;, &quot;We&quot;, &quot;Th&quot;, &quot;Fr&quot;, &quot;Sa&quot;];
var n_weekstart = 1; // day week starts from (normally 0 or 1)

var dt_datetime = (str_datetime == null || str_datetime ==&quot;&quot; ? new Date() : str2dt(str_datetime));
var dt_prev_month = new Date(dt_datetime);
dt_prev_month.setMonth(dt_datetime.getMonth()-1);
var dt_next_month = new Date(dt_datetime);
dt_next_month.setMonth(dt_datetime.getMonth()+1);
var dt_firstday = new Date(dt_datetime);
dt_firstday.setDate(1);
dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
var dt_lastday = new Date(dt_next_month);
dt_lastday.setDate(0);

// html generation (feel free to tune it for your particular application)
// print calendar header
var str_buffer = new String (
&quot;<html>\n&quot;+
&quot;<head>\n&quot;+
&quot; <title>Calendar</title>\n&quot;+
&quot;</head>\n&quot;+
&quot;<body bgcolor=\&quot;White\&quot;>\n&quot;+
&quot;<table class=\&quot;clsOTable\&quot; cellspacing=\&quot;0\&quot; border=\&quot;0\&quot; width=\&quot;100%\&quot;>\n&quot;+
&quot;<tr><td bgcolor=\&quot;#4682B4\&quot;>\n&quot;+
&quot;<table cellspacing=\&quot;1\&quot; cellpadding=\&quot;3\&quot; border=\&quot;0\&quot; width=\&quot;100%\&quot;>\n&quot;+
&quot;<tr>\n <td bgcolor=\&quot;#4682B4\&quot;><a href=\&quot;javascript:window.opener.show_calendar('&quot;+
str_target+&quot;', '&quot;+ dt2dtstr(dt_prev_month)+&quot;');\&quot;>&quot;+
&quot;<img src=\&quot;prev.gif\&quot; width=\&quot;16\&quot; height=\&quot;16\&quot; border=\&quot;0\&quot;&quot;+
&quot; alt=\&quot;previous month\&quot;></a></td>\n&quot;+
&quot; <td bgcolor=\&quot;#4682B4\&quot; colspan=\&quot;5\&quot;>&quot;+
&quot;<font color=\&quot;white\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;
+arr_months[dt_datetime.getMonth()]+&quot; &quot;+dt_datetime.getFullYear()+&quot;</font></td>\n&quot;+
&quot; <td bgcolor=\&quot;#4682B4\&quot; align=\&quot;right\&quot;><a href=\&quot;javascript:window.opener.show_calendar('&quot;
+str_target+&quot;', '&quot;+dt2dtstr(dt_next_month)+&quot;');\&quot;>&quot;+
&quot;<img src=\&quot;next.gif\&quot; width=\&quot;16\&quot; height=\&quot;16\&quot; border=\&quot;0\&quot;&quot;+
&quot; alt=\&quot;next month\&quot;></a></td>\n</tr>\n&quot;
);

var dt_current_day = new Date(dt_firstday);
// print weekdays titles
str_buffer += &quot;<tr>\n&quot;;
for (var n=0; n<7; n++)
str_buffer += &quot; <td bgcolor=\&quot;#87CEFA\&quot;>&quot;+
&quot;<font color=\&quot;white\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;+
week_days[(n_weekstart+n)%7]+&quot;</font></td>\n&quot;;
// print calendar table
str_buffer += &quot;</tr>\n&quot;;
while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
dt_current_day.getMonth() == dt_firstday.getMonth()) {
// print row heder
str_buffer += &quot;<tr>\n&quot;;
for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
if (dt_current_day.getDate() == dt_datetime.getDate() &&
dt_current_day.getMonth() == dt_datetime.getMonth())
// print current date
str_buffer += &quot; <td bgcolor=\&quot;#FFB6C1\&quot; align=\&quot;right\&quot;>&quot;;
else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
// weekend days
str_buffer += &quot; <td bgcolor=\&quot;#DBEAF5\&quot; align=\&quot;right\&quot;>&quot;;
else
// print working days of current month
str_buffer += &quot; <td bgcolor=\&quot;white\&quot; align=\&quot;right\&quot;>&quot;;

if (dt_current_day.getMonth() == dt_datetime.getMonth())
// print days of current month
str_buffer += &quot;<a href=\&quot;javascript:window.opener.&quot;+str_target+
&quot;.value='&quot;+dt2dtstr(dt_current_day)+&quot;'; window.close();\&quot;>&quot;+
&quot;<font color=\&quot;black\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;;
else
// print days of other months
str_buffer += &quot;<a href=\&quot;javascript:window.opener.&quot;+str_target+
&quot;.value='&quot;+dt2dtstr(dt_current_day)+&quot;'; window.close();\&quot;>&quot;+
&quot;<font color=\&quot;gray\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;;
str_buffer += dt_current_day.getDate()+&quot;</font></a></td>\n&quot;;
dt_current_day.setDate(dt_current_day.getDate()+1);
}
// print row footer
str_buffer += &quot;</tr>\n&quot;;
}
// print calendar footer
str_buffer +=
&quot;<form name=\&quot;cal\&quot;>\n<tr><td colspan=\&quot;7\&quot; bgcolor=\&quot;#87CEFA\&quot;>&quot;+
&quot;<font color=\&quot;White\&quot; face=\&quot;tahoma, verdana\&quot; size=\&quot;2\&quot;>&quot;+
&quot;Time: <input type=\&quot;text\&quot; name=\&quot;time\&quot; value=\&quot;&quot;+dt2tmstr(dt_datetime)+
&quot;\&quot; size=\&quot;8\&quot; maxlength=\&quot;8\&quot;></font></td></tr>\n</form>\n&quot; +
&quot;</table>\n&quot; +
&quot;</tr>\n</td>\n</table>\n&quot; +
&quot;</body>\n&quot; +
&quot;</html>\n&quot;;

var vWinCal = window.open(&quot;&quot;, &quot;Calendar&quot;,
&quot;width=200,height=250,status=no,resizable=yes,top=200,left=200&quot;);
vWinCal.opener = self;
var calc_doc = vWinCal.document;
calc_doc.write (str_buffer);
calc_doc.close();
}
// datetime parsing and formatting routimes. modify them if you wish other datetime format
function str2dt (str_datetime) {
var re_date = /^(\d+)\-(\d+)\-(\d+)/;
if (!re_date.exec(str_datetime))
return alert(&quot;Invalid Datetime format: &quot;+ str_datetime);
return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
}
function dt2dtstr (dt_datetime) {
return (new String (
dt_datetime.getDate()+&quot;-&quot;+(dt_datetime.getMonth()+1)+&quot;-&quot;+dt_datetime.getFullYear()+&quot; &quot;));
}
function dt2tmstr (dt_datetime) {
var now
now=new Date()

return (new String (
now.getHours()+&quot;:&quot;+now.getMinutes()+&quot;:&quot;+now.getSeconds()));
}
 
wow many thanks for you help, i'll try the code asap!
 
Hi there,

I've just set up an intranet, and was wondering if the following is possible with some javascript.

What I want to do is on the front page, set it that a password needs to be entered. However, I want to create the user list, so only people on the user list, can log in.

Can anyone help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top