/    Sign up×
Community /Pin to ProfileBookmark

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);
}”

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERJan 29.2013 — 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.
×

Success!

Help @simeons spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...