Click to See Complete Forum and Search --> : turning a generated date into a link


wobble
04-02-2003, 08:00 AM
Hi

I use a javascript calendar to place a date into a html form field. The date is displayed in the format dd/mm/yyyy. I wish to create a script that will take what is in that field and convert it to a link eg:

01/04/2003 should convert into a link to pdf/Business_List_01Apr.pdf and so on.

Ideally I would like the submit button on the form to run this script and locate the file pdf/Business_List_01Apr.pdf

Any ideas would be greatly appreciated.

-----
Code pasted below is just for the simple form html page
NB. OnClick command has not yet been set

<HEAD>
<script language="JavaScript" src="date-picker.js"></script>
<title>Input Calendar</title>
</HEAD>
<BODY>

<center>
<form name="calform" Action="">
<a href="javascript:show_calendar('calform.datebox');" onMouseOver="window.status='Date Picker';return true;" onMouseOut="window.status='';return true;"><img src="show-calendar.gif" width=24 height=22 border=0></a>
<input type=text name="datebox" size=15>
<INPUT TYPE=button VALUE="Get Business List" OnClick=GetBusinessList name="butone">
</form>
</center>

</BODY>
</HTML>

havik
04-02-2003, 08:52 AM
date(x) {

thedate="Inputstring: "+x+"<br>";
a=x.split('/');

// if the date was entered in this format DD/MM/YY, then:
// a[0] = DD
// a[1] = MM
// a[2] = YY
// Do this: (a[i] * 1) whenever you need the numeric value
// since a[i] contains only the string

Using this info, you could find out the date easily and do something like the following:

document.write('<a href="pdf/Business_List_' + day + month + '.pdf">link</a>');

where day is something like 01, and month could be Apr

Havik

wobble
04-10-2003, 04:42 AM
I have tried using the above reply (cheers Havik), but still can't get it to work. I'm not too sure how to incorporate your replied suggestion into the file. Does anyone have any suggestions as to how to get this to work or to point me in the right direction.

Many thanks in advance

Wobble