Page 1 of 1

calendar component in webevent

Posted: Tue Dec 13, 2022 2:28 pm
by esobel
We use calendar component controlled by JavaScript in webevent systems. JavaScript was written many years ago and worked in IE browser. Calendars stopped functioning in Chrome or MS Edge browsers. JavaScript for calendar uses name attribute, and it' doesn't work in chrome because chrome and edge use ID attribute - “The thing is, IE browse can somehow work it out even if the input only has a name attribute. But for the case of Firefox and Chrome, getElementById does not work until there is an id attribute in the control.”
(https://stackoverflow.com/questions/220 ... 2_22005710)
If you have a webevent app with calendar component functioning in chrome, can you help to get my JavaScript to work or share your JavaScript here please?

Re: calendar component in webevent

Posted: Tue Dec 13, 2022 4:21 pm
by BrendanB
Change your input button to have an id and it should work fine.
So change:

Code: Select all

<input type="text" readonly="readonly" class="blackcopy" name="txtReadyDate" id="txtReadyDate" size="10" maxlength="10" value="">
<input type="button" name="btnStartShipDate" style="width: 30px; height: 19px" value="..."/>
TO THIS:

Code: Select all

<input type="text" readonly="readonly" class="blackcopy" name="txtReadyDate" id="txtReadyDate" size="10" maxlength="10" value="">
<input type="button" id="btnStartShipDate" name="btnStartShipDate" style="width: 30px; height: 19px" value="..."/>
for more modern browsers you can also do

Code: Select all

<input type="date" id="start" name="trip-start"
       value="2018-07-22"
       min="2018-01-01" max="2018-12-31">
This will likely not work in IE, but in Firefox,Chrome,Edge,Safari and Opera it will work just fine.

Re: calendar component in webevent

Posted: Wed Dec 14, 2022 9:04 am
by esobel
Thanks Brandan!! The thing is we don't use input button. Here is the text field and small image. When I click on it, JavaScript function PopCalendar used to pop-up a small calendar (Z_CALENDAR.HTM) stored on IFS, and this calendar has its own javascript. So the calendar is not even popping up in new browsers. I may just need to run it thru the debugger to see why it's failing to execute this script.

<INPUT NAME="ASC_FDATE1" TYPE="TEXT" MAXLENGTH="010" SIZE="10" VALUE='<RDML MERGE="SC_FDATE1" >'> <IMG ALT="Click here for calendar prompt" BORDER=0 SRC="<RDML MERGE="*LW3SETCALICON2">"TABINDEX="-1" onclick="PopCalendar(document.LANSA.ASC_FDATE1,'L')">

function PopCalendar(dField, dFormat)
{

var dialogwinOptions;
dateField = dField;
dateFormat = dFormat;

dialogwinOptions = "dialogLeft:" + (screen.width - 1000) + "px; dialogTop:20px;scrollbar:no;scroll:no;status:false;dialogWidth:210px;dialogHeight:260px";
showModalDialog("/images/include/Z_CALENDAR.HTM",window,dialogwinOptions);
}

Re: calendar component in webevent

Posted: Mon Jan 09, 2023 12:19 pm
by Tim McEntee
Hi esobel

IE probably did some hoop jumping with their javascript engine to get the first element found with name= when no id= was found. The Chrome engine looks to be stricter and is just looking at the id attribute.

You can change your javascript to use let myElements = document.getElementsByName() then use the first entry found let myElement = myElements[0] - or if more than one with the same name= attribute then you will have to work out which to use.

Tim