English 中文(简体)
利用JQuery来改变降级菜单
原标题:Using JQuery to change a drop-down menu s selected option

如何着手制定一些《联邦法典》,以改变男子的选定价值。

我的网页一如上,就减少了菜单:

<select id="select_Day">
    <option value="Monday">Monday</option>
    <option value="Tuesday">Tuesday</option>
    <option value="Wednesday">Wedsnesday</option>
    <option value="Thursday">Thursday</option>
    <option value="Friday">Friday</option>
    <option value="Saturday">Saturday</option>
    <option value="Sunday">Sunday</option>
</select>

第1页的正值随后从另一页的表格中取而代之。

<?php
    $day = $_GET[ day ];
?>

然后,我将购买力平价变量的数值复制到一些javascript变量:

$(document).ready(function(event){
    var day = <?php echo $day ?>; 
});

那么,如果该页数通过价值周五,那么该选择如何作为选定的选择,?

问题回答
$(document).ready(function(event){
    var day = <?php echo $day ?>; 
    $( #select_Day ).val(day);
});

最好在html中选择“选择”你想要选择哪一种选择,然后选择使用 j子,因为它甚至在老的浏览器中工作,或者如果 j子被弃。 你们可以尝试这样的事情:

       <?php 
$arr = array( Monday ,  Tuesday ,  Wednesday ,  Thursday , Friday , Saturday , 
    Sunday );
        for($i = 0; $i < count($arr); $i++) {
           $selected = ($arr[$i] == $day) ?  selected="selected"  :   ;
           echo "<option value="{$arr[$i]}" {$selected}>{$arr[$i]}</option>";
        }
?>




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签