开发者

Button does not redirect [closed]

开发者 https://www.devze.com 2023-01-31 04:51 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

I have the f开发者_如何学编程ollowing line of code on my website that won't direct to the mentioned link

<?php

    echo '<input name="" type="button" onClick="location.href=\'main.php?user=\''.$_GET['user'].'" style="width: 150px; height: 150px; font-size: 36px; font-weight:bold; font-style: italic;" value="Done">';

?>

Is there anything wrong with the structure of my code?


You have placed the value outside the string, so that the code generated looks for example like this:

onClick="location.href='main.php?user='42"

This will cause a syntax error, and the code will not run.

Place the apostrophe after the value:

onClick="location.href=\'main.php?user='.$_GET['user'].'\'"


typo... you have onCick instead of onClick event ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消