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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date auto inserted 1

Status
Not open for further replies.

redbay

Technical User
Oct 13, 2003
145
GB
I have a checkbox and i would like if the box is clicked then the date field is automatically filled in as the current date.....any help please?
 
Use javascript, something like
Code:
<script language="Javascript">
<!--

var today = new Date()
var month = today.getMonth() + 1
var day = today.getDate()
var year = today.getFullYear()
var s = "/"
function insDate(){
document.forms.form1.myDate.value = day + s + month + s + year
}
//-->
</script>
<form name="form1" method="post" action="">
  <p>
    <input name="myCheck" type="checkbox" id="myCheck" value="checkbox" onClick="insDate()">
</p>
  <p>
    <input name="myDate" type="text" id="myDate">
</p>
</form>

Cheech


[Peace][Pipe]
 
Cheech i am trying to put the above code into an update but cant get it to work, can you advise please. heres the code

<input <%If (CStr((rsactedit.Fields.Item("InitialResponse").Value)) = CStr("True")) Then Response.Write("checked") : Response.Write("")%> name="InitialResponse" type="checkbox" id="InitialResponse" value="<%=(rsactedit.Fields.Item("InitialResponse").Value)%> onClick="insDate()">
 
You are only going to have the insdate() function called when the value of the text box is changed. I guess you want the text box filled in dependant on the value of the InitialResponse. You will need to alter the code to add the value you require.

Cheech

[Peace][Pipe]
 
You will need to add an if statement to the textbox to decide its value

Cheech

[Peace][Pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top