Havoux Havoux - 2 years ago 160
Javascript Question

PHP Concatenate Variable in URL string

<td><input type="submit" onClick="window.location.href='https://www.'.$myVariable.'.test.com'" value="Click!"></td>

I have a button that should go to 1 of 8 possible url's - I have the logic to get the variable however I seem to run into an issue here. I get an error saying

Unresolved Variable: $myVariable

Is this because I am within a HTML table?

I even tried using
between the strings and still didnt work. Am I missing something obvious?

Answer Source

Just output php variable inside one string:

<td><input type="submit" onClick="window.location.href='https://www.<?php=$myVariable; ?>.test.com'" value="Click!"></td>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download