/    Sign up×
Community /Pin to ProfileBookmark

Javascript Functions and onChange

I have a problem thats puzzling me big time and although i have more complex functions on the page this will not work

I have 3 fields and on the 3rd field i call the functions below

<select name=”kAway” id=”kAway” onChange=”populateAway(this);populateaplayers(this);” onBlur=”popFixtureDate(this);”>

This at the moment is the fuction but just wont activate although the other 2 functions do .

<script> function popFixtureDate(0)
{
alert(‘Populating FixtureDate’);
var d=document.getElementById(‘KFDate’);
var h=document.getElementById(‘kHome’);
var a=document.getElementById(‘kAway’);
var hometeam = h.value.split(‘|’,1);
alert(hometeam);
var awayteam = a.value.split(‘|’,1);
alert(awayteam);
}
</script>

Anyone have any ideas why this wont work??

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorApr 07.2011 — <i>
</i>function popFixtureDate([COLOR="Red"]0[/COLOR]){}

as long as you send an argument to a function, write it as a variable (even if you don't use it)
<i>
</i>function popFixtureDate([COLOR="Blue"]obj[/COLOR]){}

Or simply don't send an argument if you don't need it
<i>
</i>onblur="popFixtureDate()
...
function popFixtureDate(){
}
Copy linkTweet thisAlerts:
@alancregeenauthorApr 07.2011 — Already tried that also and still nothing
Copy linkTweet thisAlerts:
@KorApr 07.2011 — Call that function [B]onchange[/B], as well. After all, [I]the onchange event occurs when [COLOR="Blue"]a control loses the input focus[/COLOR] and its value has been modified since gaining focus[/I]. (see also the W3C specification). To [I]lose the focus[/I] means onblur ?, thus [B]onchange[/B] "contains" the [B]onblur[/B] as well.
Copy linkTweet thisAlerts:
@alancregeenauthorApr 07.2011 — Sorry Kor

Yes tried it onChange also and still no joy

Just cant understand it as i have 8 other functions that work fine
Copy linkTweet thisAlerts:
@KorApr 07.2011 — <i>
</i>h.value.split('|'[COLOR="Red"],1[/COLOR])

I guess you wanted:
<i>
</i>h.value.split('|')[COLOR="Blue"][1][/COLOR]
×

Success!

Help @alancregeen 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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