How to dynamically load a value into a text field?
I am having a small problem with pushing a value into a input text field and have it pass on to the next step upon submitting a form in IE.
This process works just fine i开发者_JS百科n FF and Chrome and pretty much every other browser.
Here is the input field:
<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 -->
What I need to happen is pass to the text input field an amount of donation. Here is the script behind that, which is working just fine in FF and other browsers:
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('');
}
}
I don't know why this is not working in IE...
Thanks,
Any help would do.
Matt
I'm guessing that IE does not respect the :checked
selector on a text input. Use a class selector instead.
<!-- in the form -->
<input type="text" ... class="checked" />
// and the javascript
$("input.checked:text").val(totalprice);
$("input.checked:text").html(totalprice)
try to used this
IE only allows exception not like on other browsers
please use this var test = $("input[id^='level_other']").val(); alert(test);
and it works find on both browsers bye
精彩评论