tags:

views:

90

answers:

2

In IE, The selector for multiple inputs is not working whereas in firefox it is. Below is the html.

   <td><input id="contactInfo.shippingAddress.streetAddress1" name="contactInfo.shippingAddress.streetAddress1" onchange="needToConfirm = true;" type="text" value="address1" maxlength="100"/></td>


<td><input id="contactInfo.shippingAddress.city" name="contactInfo.shippingAddress.city" onchange="needToConfirm = true;" type="text" value="city" maxlength="100"/></td>
   <td ><input id="contactInfo.shippingAddress.state" name="contactInfo.shippingAddress.state" onchange="needToConfirm = true;" type="text" value="state" maxlength="100"/></td>
   <td><input id="contactInfo.shippingAddress.addressZipCode" name="contactInfo.shippingAddress.addressZipCode" onchange="needToConfirm = true;" type="text" value="123456" maxlength="10"/>
   </td>
   <td><select id="contactInfo.shippingAddress.country" name="contactInfo.shippingAddress.country" class="dropDown" onchange="needToConfirm = true;">
   </td>

and below is jquery used -

$("*[id^='contactInfo\\.shippingAddress']").val("");

Any thoughts as to where the problem might be..

+1  A: 

Ok got a better solution, based on actually using input boxes, not checks :)

$('input[id^="contactInfo.shippingAddress"]').val('')

Just tested that in IE8 and it works fine.

Russ C
But there are other id's starting with contactinfo like input id="contactInfo.permanentAddress.streetAddress1" name="contactInfo.permanentAddress.streetAddress1" onchange="needToConfirm = true;" type="text" value="Line1" maxlength="100"/>So, need to choose onlt what is needed
JWhiz
@Russ - That doesnot work $(*[id^='contactInfo\\.shippingAddress']).attr('checked', true);Syntax error
JWhiz
Actually, I didn't down vote... I don't know how it happened.. and i don't want to checked attribute.. to check bos.. I am trying reset the html input box..
JWhiz
Updated my answer properly.
Russ C
@Russ.. Thanks that worked... now wondering why i didn't try of the various combinations !!!!
JWhiz
@JKb, No worries - glad to be of service!
Russ C
A: 

Although it is a valid character, I would guess that IE doesn't like the period in the IDs. Can you change the IDs and use a hyphen or underscore instead?

EDIT: D'oh! Got it now. The selector needs to be [id^='contactInfo.shippingAddress'] with no backslashes.

In an ID selector the period needs to be escaped because it otherwise indicates a class selector. This is however a attribute selector and we're inside a string, so there is no danger of confusion with a class selector.

Your selector worked in FF (and it works in IE8 in standards mode) because jQuery then uses the browser own CSS selector engine which has no problems with the unnecessary escapes. In IE quirks mode however jQuery's selector engine Sizzle is used and that doesn't ignore them. IMO this is a Sizzle bug.

RoToRa
Actually IE is correctly detecting period. Like.. This code snippet is working$('#contactInfo\\.shippingAddress\\.streetAddress1').val($('#contactInfo\\.permanentAddress\\.streetAddress1').val()); $('#contactInfo\\.shippingAddress\\.city').val($('#contactInfo\\.permanentAddress\\.city').val());Only problem is the selector$("*[id^='contactInfo\\.shippingAddress']").val("");is not working
JWhiz
@RotoRa.. Thanks for the info .. correct.. this seems to be a bug..since even though we explicitly mention it to be escaped it's ignoring it..
JWhiz