【问题标题】:How to make button link clickable in php echo?如何在 php echo 中使按钮链接可点击?
【发布时间】:2018-07-03 23:02:38
【问题描述】:

我有这段代码,但每次单击按钮时,它都会指向story.php,而忽略了其他细节。 我尝试过使用 javascript,但似乎使用表单操作是我实现这一目标的最接近的方法:

<form action='./story.php?u=$id'><button type='submit' class='w3-button w3-theme-d1 w3-margin-bottom'><i class='fa fa-thumbs-up'></i>$likes  Like</button> 
    <button type='submit' class='w3-button w3-theme-d2 w3-margin-bottom'>   
</form><i class='fa fa-comment'></i>  Comment$comments</button> 

【问题讨论】:

  • 什么JavaScript?什么“其他细节”?请澄清实际问题是什么。
  • &lt;/form&gt; 标签不应该在 &lt;button&gt;&lt;/button&gt; 内。
  • 查看代码源。是变量显示还是值?当按钮提交表单时,除了u 之外,没有其他输入可以实际提交。
  • 我已经编辑了代码,是的,变量在源代码上显示了正确的链接。但是当它被点击时,它只需要我去story.php
  • 我不确定您在这里期待什么。表格submit 将转到所述表格的action。你没有任何东西可以控制submit 事件来防止任何类型的默认。

标签: php html forms echo


【解决方案1】:

您缺少一个方法,无论是发布还是获取

<form action="./story.php?u=12" method="post" >
<button type='submit' class='w3-button w3-theme-d1 w3-margin-bottom'><i class='fa fa-thumbs-up'></i> $likes  Like</button> 

<button type='submit' class='w3-button w3-theme-d2 w3-margin-bottom'><i class='fa fa-comment'></i>  Comment $comments</button> 
    
</form>

现在可以正常使用了

【讨论】:

    猜你喜欢
    • 2019-07-12
    • 1970-01-01
    • 2014-02-24
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    • 2022-06-15
    • 2020-11-29
    • 1970-01-01
    相关资源
    最近更新 更多