Works perfect in IE, but not fully in Firefox
Hello, i am very angry. I wrote this code. Partially it works fine in Firefox but not in one case (which is almost the same as others).
It all works in IE.
This is the code:
onclick="if (this.value == 1) {
if (getElementById('start_date').value.substring(3,5) <= 6) {
if (parseInt(getElementById('start_date').value.substring(3,5)) + 6 <= 9) {
getElementById('end_date').value =
getElementById('start_date').value.substring(0,2) + '-' +
'0' + String(parseInt(getElementById('start_date').value.substring(3,5)) + 6) + '-' +
getElementById('start_date').value.substring(6,10);
} else {
getElementById('end_date').value =
getElementById('start_date').value.substring(0,2) + '-' +
String(parseInt(getElementById('start_date').value.substring(3,5)) + 6) + '-' +
getElementById('start_date').value.substring(6,10);
}
} else {
//it does not work here
getElementById('end_date').value =
getElementById('start_date').value.substring(0,2) + '-' +
'0' + String(parseInt(getElementById('start_date').value.substring(3,5)) - 6) + '-' +
String(parseInt(getElementById('start_date').value.substring(6,10)) + 1);
}
}
else {
if (this.value == 2) {
period = 1;
}
else {
period = 2;
}
getElementById('end_date').value =
getElementById('start_date').value.substring(0,2) + '-' +
getElementById('start_date').value.substring(3,5) + '-' +
String(parseInt(getElementById('start_date').value.substring(6,10)) + period);
}"
First off, what is it supposed to do? In what context does the event get triggered?
Second, how about a brief example of the HTML that will call the onclick event?
Third, it would be better to call the event to a function rather than try to embed all the code in-line.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks