mschwarz
Newbie
Posts: 1
Registered: 9/11/2006
Member Is Offline
|
| posted on 9/11/2006 at 11:19 AM |
|
|
Fill two option fields with same date
I would like to fill a start date and end date with the same date. Then if the end date needs to be different the the start date, use a second
instance of the picker to fill that field. (this already works.
This is what I have:
In the <b>head</> tag:
<!-- This line needed for calendar picker -->
<script language="JavaScript" src="calendar.js"></script>
<!-- End calendar picker -->
In the <b>body</b>:
<p><b>Start Date: </b>
<input name="startdate" type="text" size="15">
<a href="javascript:cal1.popup();"><img src="../../img/cal.gif" width="16" height="16" border="0" alt="Click to insert date using
a picker."></a>
<b>End Date: </b>
<input name="enddate" type="text" size="15">
<a href="javascript:cal2.popup();"><img src="../../img/cal.gif" width="16" height="16" border="0" alt="Click to insert date using
a picker."></a>
After the <b>form:</b>
<!-- Start code for calendar picker -->
<script language="JavaScript">
var cal1 = new calendar2(document.forms['NewItem'].elements['startdate']);
cal1.year_scroll = true;
cal1.time_comp = false;
var cal2 = new calendar2(document.forms['NewItem'].elements['enddate']);
cal2.year_scroll = true;
cal2.time_comp = false;
//-->
</script>
<!-- End code for calendar picker -->
I'm think the script needs something added to fill both the start date and end date with the date from the 1st picker.
Thanks in advance,
~Mark
|
|
|
Chopenko
Junior Member
Posts: 9
Registered: 10/30/2007
Location: México
Member Is Offline
|
| posted on 10/30/2007 at 11:52 PM |
|
|
Without modifications to the code, You have to set an "OnPropertyChange" event for your INPUT FIELD and then calling a function to copy the value
from the original INPUT FIELD to the second FIELD.
<html>
<head>
<script language="JavaScript">
function MyCopyFunction(){
document.all.MyForm1.MyField2.value=document.all.MyForm1.MyField1.value;
}
</script>
</head>
<body>
<form name="MyForm1" method="post">
<input type="Text" name="MyField1" onPropertyChange="MyCopyFunction()">
<input type="Text" name="MyField2">
</form>
</body>
</html>
|
|
|
moonchilddave
Junior Member
Posts: 4
Registered: 10/30/2007
Location: Leonardtown, MD
Member Is Offline
|
| posted on 10/31/2007 at 08:14 PM |
|
|
This works in IE, but not in Firefox... anyone have any idea why? Or what can be done to make it work in both browsers?
|
|
|
Chopenko
Junior Member
Posts: 9
Registered: 10/30/2007
Location: México
Member Is Offline
|
| posted on 1/10/2008 at 01:55 AM |
|
|
Sorry
Hi moonchilddave, sorry for the late answer but I didn't even know I got a Message.
I saw this when another user replied to my other thread.
Well, I took that event code from a JavaScript on MSDN.
I was trying to use onChange event, but then i looked into a newer JavaScript reference documentation and found "OnPropertyChange".
Maybe you can search here, http://developer.mozilla.org/en/docs/JavaScript.
|
|
|