I have 2 text field in a form.
1st field for input date.
I want to use onclick event handler for 2nd text field. When user click 2nd text field then show up the value of 10 days before the input date in 1st field. how do i do that?
I try this:
<input type="text" name="Balancedue" onclick="document.form.balancedue.value=dateadd("d",-10,"document.form.eventdate.value")">
it doesnt work.
thanks

Recommended Answers

All 2 Replies

You can cal the Date() function on onClick event and display the old date in the first field you should disable the first field .i think this is what u want ......just see the code below

<script type="text/javascript">
var mm =
function setday(obj){
this.y = obj.getFullYear();
this.m = obj.getMonth();
this.d = obj.getDate();
}
function ShowDate(){
var today = new Date();
var dd = new setday(today);
var h = today.getHours();
var tomor = new Date(dd.y,dd.m,dd.d-10);
var tt = new setday(tomor);
var theDay =(h>=14)?tt:dd;
var real=theDay.d+' '+mm[theDay.m]+' '+theDay.y;
document.menuform.name2.value=real;
alert(real)
}
</script>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.