/    Sign up×
Community /Pin to ProfileBookmark

perl variable passed to onchange call to javascript

Is it possible to call a javascript function with an onchange call giving it a perl variable from the calling program
Here is a sample code of what I mean
Perl
my $count = 150;

<select name=”social” onchange=”checkLimit (this. $count)”>

javascript
function checkLimit(element,now){
var c = element.value;
alert (“now is ” + now); ###this gives $count is not defined although it is used throughout the perl program with no problem.
var space = 175 – now;
if (c > space) {
alert(“Sorry we have only ” + space + ” spaces left”);
element.selectedIndex = 0;
}

}

We want to limit the total number of folks registered for an event ( 175 – currently registered folks) The current # of registrants is retained in a database value and read at the beginning of the program.

Thanks – hope someone can help this novice javascripter (and relatively novice perl coder.)

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@NedalsMar 18.2008 — I'll make a guess...

'undefined' is a javascript error, not a perl error??

Should be a comma here, not a period

<select name="social" onchange="checkLimit (this, $count)">
×

Success!

Help @lmg 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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