0

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(&#39;';echo $Company;echo'&#39;)">'.$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.

1

1 Answer 1

0
<script type="text/jscript">
function manager(Value){
    $("#info2").load("manager.php?"+Value).show();
}
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

Actually I just figured out it does work as long as the company does not have any spaces.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.