I’m trying to pass a variable from a PHP array to a JavaScript function. In the PHP array I have:
echo '<a href="JavaScript:void(0);" onclick="manager('';echo $Company;echo'')">'.$Manager.'</td>
If I use the function,
<script type="text/jscript">
function manager(Value){
alert(Value);
}
</script>
The hyperlink gives me a message box with the correct company for each row, so the PHP part seems OK. Now I want to pass the Company to a page and return the result to a div. I’ve tried using,
<script type="text/jscript">
function manager() {
$.post('manager.php', { Company: var.Value},
function (output) {
$('#info2').html(output).show();
});
}
</script>
with some variations like “Company: this.Value” and “Company: (Value)” and another method like,
<script type="text/jscript">
function manager(Value){
$("#info2").load("manager.php?"+this.manager.Value);
}
</script>
If I put the company in manually like “$("#info2").load("manager.php?Company=ACME”);” it works so I know the manager.php page is OK. I’m pretty sure I just don’t know how to pass the variable though the function correctly. Any ideas? Thanks.