Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace date value in a form

Status
Not open for further replies.

ppfude

Programmer
Jul 13, 2007
1
US
I have a form with a selection box and would like to replace the completion date based on the selection "Closed" with the current date.
Here is the form:
<form name="EditForm" action="<%=m_action%>" method="post">
<tr>
<td>Initiated by</td><td><input name="InitiatedBy" type="text" value="<%=rs("InitiatedBy")%>" size="30">
&nbsp;Initated on&nbsp; <input name="Initiated" type="text" value="<%=rs("Initiated")%>" size="10"><INPUT TYPE="image" SRC="images/cal.gif" HEIGHT="19" WIDTH="19" BORDER="0" onclick="return showCalendar('Initiated', '%m/%d/%Y');">
&nbsp;Target Due Date&nbsp;<input name="TargetDueDate" type="text" value="<%=rs("TargetDueDate")%>" size="10"><INPUT TYPE="image" SRC="images/cal.gif" HEIGHT="19" WIDTH="19" BORDER="0" onclick="return showCalendar('TargetDueDate', '%m/%d/%Y');">
&nbsp;Completion Date&nbsp;<input name="CompletionDate" type="text" value="<%=rs("CompletionDate")%>" size="10"><INPUT TYPE="image" SRC="images/cal.gif" HEIGHT="19" WIDTH="19" BORDER="0" onclick="return showCalendar('CompletionDate', '%m/%d/%Y');"></td>
</tr>
<td>Issue Type</td><td><select name="Resolved" type="text" value="" size="1" onchange="doSelect(this);"><option value="New">New</option>
<option value="Open">Open</option>
<option value="Pending">Pending</option>
<option value="Closed">Closed</option>
<option value="Resolved">Resolved</option>
</select>
</td>
</tr>
<tr>
<td colspan="6">
<input type="submit" value="Save" onclick="this.disabled=true;this.value='Saving...';
this.form.submit();"><input type="button" value="Cancel" onClick="history.go(-1)">
</td>
</tr>
</form>

Here is the function:
<script type="text/javascript">
function doSelect(x)
{
if(x.options[x.selectedIndex].value="Closed")
{
document.EditForm.CompletionDate.value=(now.getDate() + "/" + now.getMonth() + "/" + now.getYear())
}
else
{
document.EditForm.CompletionDate=" "
}
</script>

This unfortunetly does not work, what do I do wrong in the function?

Your input is highly appreciated
 
>if(x.options[x.selectedIndex].value="Closed")
[tt]if(x.options[x.selectedIndex].value[red]==[/red]"Closed")[/tt]
Actually, can further simplify it like this.
[tt]if(x.value=="Closed")[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top