2012-06-08 52 views
1

我想知道如何在JQuery中做些什麼,我需要一點幫助。我認爲我需要做的是RegEx搜索,然後匹配特定字段。JQuery問題 - Magento自定義字段

我基本上有一個Magento的店,它有3個自定義字段,它們都具有類似下面

options_22_text 
options_23_text 

基本上他們已經options_number_text的名稱(用隨機數代替數)。

對於每個頁面,我需要接機的3個自定義字段(它們的順序依次顯示在頁面上)和

這是我迄今爲止得到的,但由於數量的變化這是行不通的對於所有頁面

jQuery(document).ready(function() { 
    if (jQuery('#options_3_text').length > 0){ 
     //Custom Options - Template: Description.phtml 

     jQuery('#options_2_text').click(function() { 
      //Make sure other fields are filled out first 
      if (jQuery('#options_3_text').val() == "") { 
       alert('You must enter the first line!'); 
       jQuery('#options_3_text').focus(); 
      } 
     }); 

     jQuery('#options_1_text').click(function() { 
      //Make sure other fields are filled out first 
      if (jQuery('#options_3_text').val() == "") { 
       alert('You must enter the first line!'); 
       jQuery('#options_3_text').focus(); 
      } 
     }); 
    } 
}); 

基本上人需要填寫第一個文本字段,因爲它調整價格。我需要找到一個很好的方式來做到這一點 - 請幫助!?

回答

2

$("input[id^=options_]")應該拾取以選項開頭的所有輸入元素_