2012-06-08 57 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_]")应该拾取以选项开头的所有输入元素_