普通网友 2013-04-27 16:01
浏览 77

单击li元素时将值传递给另一个页面

In my jquery mobile app, when I click a list element, I get the id of that element. Now I want to pass that id to another page so I can make a query to the database. What would be the best way to achieve this? I tried with a form to post the id, but I don't want a form with a submit button on the page. I also tried using sessionStorage, but I am unsure how to use it properly. Presently, when I click a list element, an alert shows me the id of that selected list element.

<script>
    $(document).ready(function(){
        $("li").click(function() {
            var journeyID = this.id;
            sessionStorage.journeyId = journeyID;
            alert(sessionStorage.journeyId);                    
            var j = getElementById(journeyDetailsForm);
            j.innerHTML = journeyID;

            //document.forms["journeyForm"].submit();
        });
    });
</script>
  • 写回答

1条回答 默认 最新

  • dongmei8460 2013-04-27 16:13
    关注

    If you know the url of the page

    $("li").on("click",function(){
        var url = "example.com/page.php",
            id = this.id;
        window.location= url + "?id=" + id;
    
    
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?