2014-01-21 55 views
0

我有一個腳本,允許我加載頁面/內容到div而不是重新加載頁面。它還更新後退按鈕,並允許瀏覽所有內容。我已經在這個問題上使用過表格,他們工作;但是,直到現在還沒有在這些頁面中使用選擇。Javascript/jquery:腳本(與表單無關)禁用了<select>,任何人都可以看到爲什麼?

我添加了選項和選項。它加載,然後一秒鐘後,選擇文本消失,並且就好像沒有任何選項一樣。

我從頁面中刪除了這個腳本,一切正常。我看不出這裏有什麼干擾,因爲這與表單本身無關。我希望別人會看到是什麼導致了這個問題。

SCRIPT:

$(function(){ 

    $("a[rel='right']").click(function(e){ 
    e.preventDefault(); 


    //get the link location that was clicked 
    pageurl = $(this).attr('href'); 
    //to get the ajax content and display in div 
    $.ajax({url:pageurl.replace('index.php', 'rightcolumn.php')+'&rel=right',success: function(data){ 
     $('#WMS_NEW_right').fadeOut(500, function(){ $('#WMS_NEW_right').html(data).fadeIn(1000); }); 
    } 
    }); 

    //to change the browser URL to the given link location 
    if(pageurl!=window.location){ 
     window.history.pushState({path:pageurl},'',pageurl); 
    } 
    //stop refreshing to the page given in 
    return false; 
    }); 

}); 

/* the below code is to override back button to get the ajax content without reload*/ 
$(window).on('popstate', function() { 
    $.ajax({url:$(location).attr('href').replace('index.php', 'rightcolumn.php') +'&rel=right',success: function(data){ 
     $('#WMS_NEW_right').html(data); 
    }}); 
}); 

HTML表單,我使用...

<form class="formrelright" action="" method="POST"> 
Name: <input type="text" name="name" /><br /> 
Option: <select name="option" /><option value="">Option</select><br /> 
Option2: <select name="option2" /><option value="">Option</option></select><br /> 
Option3: <select name="option3" /><option value="">Option</option></select><br /> 
<input type="submit" /> 
</form> 

回答

1

你關閉你的選擇還爲時過早。

<select name="option" /> 

應該

<select name="option"><option value="">Option</option></select> 
+0

哇。我不知道我是如何設法做到這一點的。我知道我做了一個並複製了其他人。我更新了代碼,現在它可以工作。我真的很感興趣的是,當我從頁面中刪除腳本時,一切似乎都奏效了。儘管如此,謝謝你接受! – kdjernigan

相關問題