1

I don't understand why the addRow method isn't reading the parameters and I know for a fact they are initialized.

In php
echo "<script> addRow(".$song.",".$artist."); </script>";

JavaScript method

function addRow(s,a){
        document.write("test");
    }
2
  • echo "<script> addRow('".$song."','".$artist."'); </script>";//quote values Commented Apr 30, 2015 at 13:54
  • Or for better readability, no need to concatenate: echo "<script> addRow('$song', '$artist'); </script>"; Commented Apr 30, 2015 at 13:57

2 Answers 2

1

Don't forget your quotes!

echo "<script> addRow( '".$song."', '".$artist."' ); </script>";

Or nicer even:

echo "<script> addRow( '{$song}', '{$artist}' ); </script>";
Sign up to request clarification or add additional context in comments.

Comments

0

PHP

<script> addRow('".$song."','".$artist."'); </script>

JavaScript

function addRow(s,a){
    console.log(s);
    console.log(a);
    document.write("test");
}

3 Comments

im sorry what is the console.log for?
The JavaScript part is not of particular value.
console.log is for the display of params, when you try to get them in your function, it is nice to verify it works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.