Reputation: 111
I have a button in php that will not redirect. Assume the page destination is correct, is anything else wrong with this line?
echo "<button id=\"create\" onclick=\"location.href('/team/teams.php?op=create');\">Create Team</button><br>";
thanks!
Upvotes: 0
Views: 174
Reputation: 109
The javascript syntax is:
location.href = 'url_to_go';
So just delete the bracket and give an equal sign after 'location.href' Here is the code look like:
echo "<button id=\"create\" onclick=\"location.href = '/team/teams.php?op=create';\">Create Team</button><br>";
Upvotes: 0
Reputation: 3315
try
<button id='create' onclick='window.location=\"/team/teams.php?op=create\";'>Create</button>
Upvotes: 0
Reputation:
Maybe try this?
echo "<button id=\"create\" onclick=\"location.href='/team/teams.php?op=create';\">Create Team</button><br>";
Upvotes: 0
Reputation: 388446
location.href
is not a function, it is a property so
onclick=\"location.href = '/team/teams.php?op=create';\"
In your case, there should be an error in your browser console saying Uncaught TypeError: string is not a function
Upvotes: 1