0

I have this line of code which works well, but I want to convert into a PHP variable:

<a href="javascript:void(0);" onClick="javascript:freezModel('view_assumptions.php?id=<?php echo $adminArr['id'];?>&act=freez')" >

I have tried this:

$unlock='<a href="javascript:void(0);" onClick="javascript:freezModel("view_assumptions.php?id='.$adminArr["id"].'&act=freez")" class="actionIcons unlocked"></a>';

I thought it was an escaping issue so I added the back slashes before the second ":

$unlock='<a href="javascript:void(0);" onClick="javascript:freezModel(\"view_assumptions.php?id='.$adminArr["id"].'&act=freez\")" class="actionIcons unlocked"></a>';

But still no luck. Why does this not work???

2 Answers 2

1

You must use ' instead of " for freezModel(), and scape it:

$unlock = '<a href="javascript:void(0);" onClick="javascript:freezModel(\'view_assumptions.php?id='.$adminArr["id"].'&act=freez\');" class="actionIcons unlocked"></a>';

Using " you are closing your onclick property.

Sign up to request clarification or add additional context in comments.

Comments

1

Your situation will be better handled using heredoc.

Try this instead:

<?php
$unlock = <<<EOS
<a href="javascript:void(0);" onClick="javascript:freezModel('view_assumptions.php?id={$adminArr['id']}&act=freez')" >
EOS;

Comments

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.