【发布时间】:2017-09-17 22:18:01
【问题描述】:
我有这段代码,我似乎无法正常工作,我希望我发布正确,我想让用户文本输入替换原始 href 链接 10 分钟,并可以点击其他链接访问者在此期间,然后返回到原始 href。每 10 分钟可重复一遍。任何和所有的帮助将不胜感激。
<script type="text/javascript">
function changeURLOfAnchorWithID(anchor_id,new_href)
{
document.getElementById("anchor").href = new_href;
}
function formOnSubmit(formElm)
{
changeURLOfAnchorWithID("anchor",formElm.new_url.value+"");
return false;
}
</script>
</head>
<body>
<a id="anchor" href="https://www.whatever.com/"> <!--Keeps new url active for 10 minutes after user leaves site and other visitors are able to click there submitted link instead, then resets to default setting after 10 minutes-->
<img border="0" src="https://www.whatever.com" width="468" height="60"></a>
<form onsubmit="return formOnSubmit(this)">
<input type="text" name="new_url" value="" size="36" /><br /> <!--value added to the end of the static address in the anchor tag -->
<input type="submit" value="change href" />
</form>
好的,这就是我想出的,PHP 运行良好并在单独的页面上更新信息,我希望在文本框中输入的信息替换PHP 页面上的 HREF 链接的末尾,并在此处至少停留 10 分钟,直到其他人使用那里的输入更新 PHP。我已决定在 10 分钟结束后无需将链接恢复为原始链接。
HTML
<form method="post" action="phptest.php">
<textarea name="Box" cols="20" rows="1"></textarea><br>
<input type="submit" value="Submit" />
</form>
PHP
<?php echo $_POST["Box"] ?>
【问题讨论】: