开发者

Get selected value in list in Html

I want to get the selected value in a list.

<html >
<head>
<meta charset="utf-8" />
<title>Intro to jQuery Mobile</title><br />
<!--
<script type="text/javascript" src="jquery.mobile-1.0a3.min.css"></script>
<script type="text/javascript" src="jquery.mobile-1.0a3.min.js"></script>
<script type="text/javascript" src="jquery-1.5.min.js"></script>-->
<lin开发者_如何转开发k rel="stylesheet" href="jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="jquery-1.5.min.js"></script>
<script type="text/javascript" src="jquery.mobile-1.0a3.min.js"></script>
<script type="text/javascript">
 function GetSelectedValut()
{
    var list_value = document.getElementById("search1").value;
    alert(list_value);
}
</script>
</head>
<body>
<!-- Page one starts-->
<div data-role="page" id="pageone">
    <div data-role="header">
        <h1>Header</h1>
    </div>
    <div data-role="content">
        <ul data-role="listview" data-inset="true" >
        <li id="search">
<a href="#pagetwo" value="Selected one" onclick="GetSelectedValut()">Selected one</a>
        </li>
        <li id="search1" onclick="GetSelectedValut()" value="Selected two">
            <a href="#detailpage">Selected two</a>
        </li>
        <li>
            <a href="#detailpage">Selected three</a>
        </li>
        <li>
        <a href="#detailpage">Selected four</a>
        </li>
        <li>
            <a href="#detailpage">Selected five</a>
        </li>
        <li>
            <a href="#detailpage">Selected six</a>
        </li>
        /ul>
    </div>
    <div data-role="footer">
        <h1>Footer</h1>
    </div>
</div>
<!-- Page one ends-->
</body>
</html>

If i choose selected six means, one alert box says the selected list value and also i want to bind with one tag i.e <p> paragraph in next page. thanks in advance.


function GetSelectedValut(id)
{
    var list_value = $("#"+id).attr("value");
    location = "nextpage.html?val="+encodeURIComponent(list_value);
}


    <a href="#pagetwo" value="Selected one" onclick="GetSelectedValut('search1')">Selected one</a>
    </li>
    <li id="search1" onclick="GetSelectedValut(this.id)" value="Selected two">

In next page (from this post):

function getParameterByName(name) { 
  var match = RegExp('[?&]' + name + '=([^&]*)')
    .exec(window.location.search);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}

window.onload=function() {
  $("#someParagraphID").html(getParameterByName("val"))
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜