Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7060 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hi - I'm getting to grips with FMSA custom web publishing and have a question regarding the conversion of a input date field on a form, from dd/MM/yyyy, to the standard "fm" format of MM/dd/yyyy. I've researched enough to realise this should be done client side with JavaScript but my javascript skills aren't that advanced. Does anyone know how to achieve this?

So far I figure that the date field submitted to the database (Booking Date in MM/dd/yyyy format), should be a hidden input field on the form. Then on submitting the form, the field the user completed, tempDate (in dd/MM/yyyy format) should be converted using javascript to MM/dd/yyyy and copied to the Booking Date field.

The other complication is that there are several forms which contain the different products the user may choose to book, not just a single form with one product.

Each form is named according to the following:

<xsl:attribute name="name">prodform<xsl:value-of select="$record/fmrs:field[@name = 'ID']/fmrs:data[1]"/></xsl:attribute>

which creates forms named prodform2001, prodform2002, prodform2003 etc depending on the catalogue ID.

The xsl file has the form defined as:-

<form method="POST">

<xsl:attribute name="action">bookedOK.xsl</xsl:attribute>

<xsl:attribute name="name">prodform<xsl:value-of select="$record/fmrs:field[@name = 'ID']/fmrs:data[1]"/></xsl:attribute>

<input type="hidden" name="-db" value="Booking"/>

<input type="hidden" name="-lay" value="web"/>

<input type="hidden" name="Booking Date" />

... how do I fill out the Booking Date field with MM/dd/yyyy values?...

<input type="hidden" name="-new" value=""/>

... display what's on sale...

<table width="582" border="0" cellspacing="2" cellpadding="2">

<tr><td><xsl:value-of select="$record/fmrs:field[@name = 'Products::ProductName']/fmrs:data[1]"/></td>

... temporary input field for Booking Date in dd/MM/yyyy format

<td><input type="text" name="tempDate" /></td></tr>

</table>

</form>

I'd be grateful for any suggestions on the best way to do this from within an xsl template file.

As an aside, the conversion of booking dates when displayed on the webpage has been done by using an xslt function and seems to work well:

<xsl:for-each select="fmrs:field[@name = 'Booking Date']/fmrs:data[1]">

<xsl:value-of select="fmxslt:convert_datetime('MM/dd/yyyy','EEE dd/MM/yy',.)"/>

</xsl:for-each>

Thanks for any help you can give me and cheers...

Posted

Hi, d! Welcome to FMFORUMS! Now, until someone posts exactly what you want (I'm afraid I haven't delved into xml/xsl yet and my JS is probably worse than yours), can you use FM to parse your date and re-arrange the components using CALC fields?

--ST

Posted

You can use some Javascript to reformat the date fefore the Form is submitted.

<html><head>

<script>

function moddate()

   {

   formdate = document.myform.mydate.value.split("/");

   document.myform.mydate.value = formdate[1] + "/" + formdate[0] + "/" + formdate[2];

   document.myform.submit();

   }

</script>

</head>

<body><form name="myform" action="FMPro" method="POST" onsubmit="moddate(); return false;">

<input type="hidden" name="-db" value="mydb.fp5">

<input type="hidden" name="-format" value="mypage.html">

Enter date (dd/mm/yyyy): <input type="text" name="mydate" value="">

<input type="submit" name="-new" value="Submit Form">

</form></body></html>

Good Luck.

Garry

  • 3 weeks later...

This topic is 7060 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.