[thelist] How to abstract this script?

Tom Dell'Aringa pixelmech at yahoo.com
Wed Mar 9 08:58:49 CST 2005

I've got a calendar pop up script (date picker) that I need to use in a portal we are building. On
a typical page, the user would have 4 dates from which to choose. So the script will be called 4
times for each date. The problem is that means I have to hard code 4 references to input box I am
putting the date into. I'd like to avoid that if possible, but I'm not thinking of a way to do

Here is the HTML with the function call:

<h3>Choose a Date</h3>
<form name="service">
<input type="text" name="serviceDate" id="serviceDate" /> <a href="error.html"
onclick="ShowCalendar(document.forms['service'].elements['serviceDate'].value); return false;">
<img src="calendar-icon.gif" alt="" border="0" /></a> <div id="calendar"></div>

I'm using the typical calendar icon to the right of the input box. I'd like to be able to pass
ShowCalendar() an object reference instead of a hard coded ref. Problem is the image and the input
box aren't related.

I'm wondering if maybe I wrap the input box as well as the image... maybe there is a way with the
DOM to grab first child of the A perhaps?

Any ideas?


Melissa: Ace, Where are you?
Ace Ventura: I'm in Psychoville and Finkle's the Mayor.

More information about the thelist mailing list