2010-02-22 68 views
0

我在將一個值輸入到輸入文本字段時遇到了一個小問題,並在IE中提交表單時將它傳遞給下一步。如何動態地將值加載到文本字段中?

這個過程在FF和Chrome以及幾乎所有其他瀏覽器中都能正常工作。

這裏是輸入字段:

<div id="donate_form_gift"> 
        <fieldset id="donate_form_gift_amount_fieldset"> 
        <!-- TODO: Update with the correct LEVEL_IDs for your FORM --> 
        <div style="clear: both; margin-top: 5px; color:#000;"> 
         <input type="radio" value="9705" id="level_other" name="level_id" style="display:inline; margin-top:5px;" checked="checked" /> 
         <!-- TODO: update value --> 
         <input type="text" id="other_amount" size="10" name="other_amount" value="" checked="checked" /> 
        </div> 
        </fieldset> 
       </div> <!-- /donate_form_gift --> 

我需要發生的是傳遞到文本輸入字段的捐贈量。這裏是背後的腳本,這是工作在FF和其他瀏覽器就好了:

function change(id) 
{ 
var i=findpos(id); 

totalprice+=(parseInt($('#'+id+'_cnt').val())-purchased[i].cnt)*purchased[i].price; 

purchased[i].cnt=parseInt($('#'+id+'_cnt').val()); 
update_total(); 
} 

function update_total() 
{ 
if(totalprice) 
{ 
    $('#total').html(totalprice); 
    $("input:text:checked").val(totalprice); 
    $("input:text:checked").html(totalprice); 
} 
else 
{ 
    $('#total').html(''); 
} 
} 

我不知道這是爲什麼不工作在IE ...

感謝,

任何幫助都可以。

馬特

回答

0

我猜,IE不尊重上的文本輸入:checked選擇。改爲使用類選擇器。

<!-- in the form --> 
<input type="text" ... class="checked" /> 

// and the javascript 
$("input.checked:text").val(totalprice); 
$("input.checked:text").html(totalprice) 
+0

喬爾...我會嘗試,謝謝! – TikaL13 2010-02-22 01:56:16

+0

它工作得很好!謝謝喬爾! – TikaL13 2010-02-22 01:59:53

0

嘗試用這種

IE只允許例外,不能在其他瀏覽器

喜歡請使用此 VAR測試= $(「輸入[ID^= 'level_other' ]「)VAL(); alert(test);

和它的作品找到關於這兩種瀏覽器 再見

相關問題