'Trouble passing a value from HTML5 SELECT object to JS script
I have a basic web page with an HTML5 SELECT object that has 3 elements populated in it via js/jQuery. I want to take the value selected, and pass the value to a js file that runs a perl script.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js" charset="utf-8"></script>
<script type="text/javascript" src="js/main.js" charset="utf-8"></script>
<script type="text/javascript" src="js/RunPerlScript.js" charset="utf-8"></script>
</head>
<body>
<header>
<h1></h1>
</header>
<form name="myForm" method="GET" action="">
<select id="cdLDAP" onchange="run_script_func(this.textvar
<option/>
</select>
</form>
</body>
</html>
JS File:
var selection = #cdLDAP.text
function run_script_func(val){
window.alert=val;
}
Based on my PHP admin console I know the script isn't executing. My Perl script does work as expected, if I run it by itself, so I know it is not that aspect of my code.
Am I using the onchage="" element correctly? and/or is it how the RunPerlScript.js file is structured?
Solution 1:[1]
You've only got one
<option />
in your example. For the change event to fire you probably need something to actually change. Try adding another option.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | brindy |
