【问题标题】:Web app HTML parameter passingWeb 应用程序 HTML 参数传递
【发布时间】:2013-03-07 14:50:09
【问题描述】:

我有一个网络应用程序。我正在使用链接 ...:8080/EPQ/ 访问 Web 应用程序。 Web 应用程序只有一个 HTML 文件。我在 HTML 中有以下代码。

<input type="hidden" name="id" id ="id" >

我想通过 URL ...:8080/EPQ/ 传递这个 id 的值。让我知道该怎么做。

【问题讨论】:

  • 网址格式为someip:8080/EPQ
  • 如果源html是你的,那么你可以考虑使用php传值。 url.com?variable=value
  • @lukeocom 我尝试了类似 someip:8080/EPQ/?id=1000 的查询字符串。该值未通过。 HTML 只是我的。我可以修改它。

标签: php javascript html web-applications parameter-passing


【解决方案1】:

如果您将文件更改为具有 .php 扩展名而不是 .html,则可以使用脚本检查是否已将值添加到 url。当然,您的服务器必须安装 php 才能正常工作。

一个例子在你的 php 文件中看起来像这样。

<?php
    //check if var is in URL and store it in $yourVar otherwise store the string 'blank text'
    if ($_GET) {
        $yourVar = $_GET['hidden-val'];
    } else {$yourVar = 'blank text';
    }   
?>

你的网址看起来像这样

http://www.yourdomain.com/yourfile.php?hidden-val=somevalue

或者如果文件是 index.php 你可以使用

http://www.yourdomain.com/?hidden-val=somevalue

另一种解决方案是使用 javascript/jquery 方法,看起来像..

$(document).ready(function() {
    var yourVar = window.location.search.substring(1);
    alert('you passed in ' + yourVar);
}

这个帖子也可能有帮助..How to get the value from the GET parameters?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-29
    • 2017-06-20
    • 2020-02-07
    • 2018-06-16
    • 1970-01-01
    • 2012-12-24
    • 1970-01-01
    相关资源
    最近更新 更多