dtj4307 2013-03-19 03:12
浏览 28
已采纳

Web应用程序HTML参数传递

I have a web app. I am accessing the web app using the link ...:8080/EPQ/. Web app has only one HTML file. I have the following code in HTML.

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

I want to pass value for this id through the URL ...:8080/EPQ/. Let me know how to do that.

  • 写回答

1条回答 默认 最新

  • dpjw67160 2013-03-19 05:34
    关注

    If you change your file to have a .php extension instead of .html, then you can use a script to check if a value has been added to the url. Your server must have php installed for this to work of course.

    An example would look something like this in your php file.

    <?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';
        }   
    ?>
    

    your url would look something like this

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

    or if the file is index.php you can use

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

    An alternative solution is to use a javascript/jquery approach, which would look something like..

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

    this thread may be of help also.. How to get the value from the GET parameters?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类