Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
passing a javascript variable to a perl variable
jigs
Hi,
I have a problem regarding passing a javascript variable to a perl variable. i am having a callout called from templating. there i m connecting to database thru perl and accessing a value then transferring tht to a dropdown box. here in the dropdown user will do some selection.this selected value i need to pass as a parameter in my next query. so it involoves perl and JS interaction. i dont have any idea if i can pass the JS variable value to a perl code as a parameter.
the code snippet is like this....
print <
Countries
EndOfHTML4
print '';
$sth = $dbh->prepare(qq{SELECT COUNTRY_DESC, COUNTRY_CODE FROM ZEEP_COUNTRY_MV}) || die "Can't prepare statement: $DBI::errstr";
$sth->execute || die "Can't execute statement: $DBI::errstr";
my($country_desc, $country_code);
$sth->bind_columns(undef, \$country_desc, \$country_code);
while ($sth->fetch())
{
print "";
print "$country_desc\n";
}
print '';
print <
Choose one or more cities
EndOfHTML5
print '';
print 'All\n';
$sth = $dbh->prepare(qq{SELECT CITY_CODE, CITY_DESC FROM ZEEP_CITY_MV WHERE COUNTRY_CODE='?'}) || die "Can't prepare statement: $DBI::errstr";
$sth->execute || die "Can't execute statement: $DBI::errstr";
my($cityCode, $cityDesc);
$sth->bind_columns(undef, \$cityCode, \$cityDesc);
while ($sth->fetch())
{
print "";
print " $cityDesc\n";
}
print '';
here in the second query i want to pass the value of country_code which i have in the JS variable.how to accomplish this??
please help its urgent.thanks in advance.
~Jigs
Find more posts tagged with
Comments
Migrateduser
Wow, you'll really need to attach your script since the page is now messed up :-)
In general, the only interaction you could have from a client-side language like Javascript to a server-side language like Perl on a web application like this is to force some kind of communication -- like an HTTP GET or POST. If you could have Javascript actually cause a page refresh (or redirection, etc.) with self.location or something similar, you can then pass any JS values
GriffTheDog
Put an onchange event on the dropdown that calls a callServer() and pass the value as a parameter.
I've attached an example, just change the event in the js file.