Forum Moderators: coopster & phranque

Message Too Old, No Replies

something nifty i would like to use on a form...

in "traxis" date is displayed automatically....

         

iggy99

9:44 pm on Jan 2, 2002 (gmt 0)

10+ Year Member



we have a family flowershop that I am building a new web site for, we would like to add to a "form" an automatically updating "date" field

we do still use traxis and just today i noticed that the date filter updates itself automatically....

i would assume this would have to be done on a form as an ssi include on the order form...

any ideas?

many thanks

bird

12:12 am on Jan 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From the Apache Manual, mod_include [httpd.apache.org]:

<form action="http://www.example.com/cgi-bin/process-form.cgi">
Date:<entry type="text" name="date"
value="<!--#echo var="DATE_LOCAL" -->"><br>
Name:<entry type="text" name="name"><br>
<entry type="submit" value="Ok">
</form>

This works for a form loaded from a static file (even if it is included by another mod_include directive).
If your form is created dynamically by a CGI script, then the programming language used will offer more convenient functionality to the same effect.

iggy99

7:57 pm on Jan 3, 2002 (gmt 0)

10+ Year Member



bird, thanks...

please follow this link

[webshop101.com...]

notice in the lower half of the page in the green shaded "time Range Filter"

see how todays is displayed by default???

this is a feature i would like to add to static html order forms ---

we have flower shop and this would be a nifty feature to add for our select delivery day/month drop down menues

how could i do this???

many thanks for your thoughts

netcommr

10:51 pm on Jan 3, 2002 (gmt 0)

10+ Year Member




If your server is capable of server side includes (SSI), make sure the file extension of the page is .shtml instead of .html or .htm. Then add
<!--#echo var="DATE_LOCAL" --> where you want the date to display. (as per bird's post)

For plain static pages the only way is javascript.

put this code in your page where you want the data to display.

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

<script language="JavaScript">
<!--
//------------DATE AND TIME
today = new Date()
TimeHrs = today.getHours()
TimeMin = today.getMinutes()
DateMth = today.getMonth()+1
DateDate = today.getDate()
DateYear = today.getYear()
DateDy = today.getDay()
if (TimeHrs > 12) {
TimeHrs = TimeHrs - 12
if (TimeHrs == 12) {
AmPm = "am"
} else {
AmPm = "pm"
}
} else {
if (TimeHrs == 12) {
AmPm = "pm"
} else {
AmPm = "am"
}
}
if (TimeMin < 10) {
TimeMin = "0" + TimeMin
}
if (DateMth == 1) { DateMonth = "January "
} else if (DateMth == 2) { DateMonth = "February "
} else if (DateMth == 3) { DateMonth = "March "
} else if (DateMth == 4) { DateMonth = "April "
} else if (DateMth == 5) { DateMonth = "May "
} else if (DateMth == 6) { DateMonth = "June "
} else if (DateMth == 7) { DateMonth = "July "
} else if (DateMth == 8) { DateMonth = "August "
} else if (DateMth == 9) { DateMonth = "September "
} else if (DateMth == 10) { DateMonth = "October "
} else if (DateMth == 11) { DateMonth = "November "
} else { DateMonth = "December "
}
if (DateDy == 0) { DateDay = "Sunday"
} else if (DateDy == 1) { DateDay = "Monday, "
} else if (DateDy == 2) { DateDay = "Tuesday, "
} else if (DateDy == 3) { DateDay = "Wednesday, "
} else if (DateDy == 4) { DateDay = "Thursday, "
} else if (DateDy == 5) { DateDay = "Friday, "
} else { DateDay = "Saturday"
}
brsr=navigator.appName
if (brsr=="Netscape") {
if (DateYear < 99) {
DateYear = DateYear + 2000
} else { DateYear = DateYear + 1900
}
}
document.write(DateDay + " " + DateMonth + DateDate + ", " + DateYear)
// -->
</script>

iggy99

11:23 pm on Jan 4, 2002 (gmt 0)

10+ Year Member



we need this date to be "placed" in a drop down / menue as the first available date - as it is done in the post above in the traxis program...

i can get the date in many ways "onto" the page - I need to incorporate it into a "form Element" namely a drop down list box/menue

many thanks

bird

1:27 am on Jan 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



please follow this link

That leads me to a login page...

Anyway, if I understand you correctly, then you want the right item from a dropdown preselected, so that the user doesn't need to change it in the standard case. This is done by adding the selected="selected" attribute to one of the <option> tags within a <select>.

If you want to do this automatically within a static page, then you can fiddle with SSI if/endif clauses, comparing the date with a regular expression for each item:


<select name="weekday">
<option
<!--#if expr="$DATE_LOCAL = /Monday/" -->
selected="selected"<!--#endif -->>
Monday</option>
<option
<!--#if expr="$DATE_LOCAL = /Tuesday/" -->
selected="selected"<!--#endif -->>
Tuesday</option>
<option
<!--#if expr="$DATE_LOCAL = /Wednesday/" -->
selected="selected"<!--#endif -->>
Wednesday</option>
<option
<!--#if expr="$DATE_LOCAL = /Thursday/" -->
selected="selected"<!--#endif -->>
Thursday</option>
<option
<!--#if expr="$DATE_LOCAL = /Friday/" -->
selected="selected"<!--#endif -->>
Friday</option>
<option
<!--#if expr="$DATE_LOCAL = /Saturday/" -->
selected="selected"<!--#endif -->>
Saturday</option>
<option
<!--#if expr="$DATE_LOCAL = /Sunday/" -->
selected="selected"<!--#endif -->>
Sunday</option>
</select>

Doesn't look extremely elegant in the source, but it works... ;)

Care must be taken when crafting the regular expressions for numeric parts of the date string, to ensure that they really only match the part you want. Most likely this will be done by including leading/trailing spaces and other special characters.

Ah yes, and if you don't want to use the *.shtml extension (eg. if most of your pages use SSI anyway), then you can put this into the .htaccess in the same directory:

AddHandler server-parsed .html

iggy99

4:27 am on Jan 8, 2002 (gmt 0)

10+ Year Member



many thanks