0

The following code I cannot get to work (Jquery 1.4.2) It seems like the selector is not working cause it doesn't do anything after that with the id=p_quantity. I added the .remove() just to see if it was that line that was the trouble and it did not remove the textbox in compatibilty mode, works in regular mode and FF. Stumped!!!

EDIT this line does not work.

$("input[type='textbox'][name^='QTY']").attr('id','p_quantity').remove();

Funny thing is the second remove of the two image inputs work fine in IE COMP mode

<table cellspacing="0" cellpadding="3" border="0"><tr><td>
<span class="PageText_L71n">Qty</span>: <input type="textbox" name="QTY.LL24" size="3" maxlength="7" onkeydown="javascript:QtyEnabledAddToCart();" value="1">
</td><td>

                          <input type="image" src="/v/vspfiles/templates/moderntot/images/buttons/btn_addtocart.gif" name="btnaddtocart" alt="Add to cart" border="0">

     <input type="hidden" name="ReplaceCartID" value="" />
     <input type="hidden" name="ProductCode" value="LL24" />
     <input type="hidden" name="e" value="" />

      <input type="hidden" name="ReturnTo" value="ShoppingCart.asp" />

     &nbsp;<input type="image" src="/v/vspfiles/templates/moderntot/images/buttons/btn_addtowishlist.gif" name="btnaddtowishlist" alt="Add To Wish List" border="0" />

     </td></tr>

     </table>

<script type="text/javascript" language="javascript">
$(function(){
$("input[type='textbox'][name^='QTY']").attr('id','p_quantity').remove();
$("input[type='image'][name^='btnadd']").attr('id','button').remove();    
});
</script>

1 Answer 1

1

You can't change the id and name attribtues of existing form input elements in IE6/7. You need to create a whole new DOM element and replace the original with it. See also this related question.

By the way, textbox is an invalid input type, it will then default to text. You should in fact have used type="text".

Sign up to request clarification or add additional context in comments.

4 Comments

Well I do not understand how that can be cause the second jquery input statement works fine BTW this doesn't work either $("input[type='text'][name^='QTY']").remove(); It is not changing any attributes
Ok you are correct but not about the first thing in this case but rather about the "textbox" (This code is not something I cannot change) It has "textbox" as the type, so I changed the selector to $("input[type^='text'][name^='QTY']").remove(); and it works fine all around
It truly won't work. Try selecting the element with new ID or name afterwards in JS/jQuery or submitting the form to the server side which in turn relies on the new name as parameter name.
OUCH!!! you are right on both accounts, just checked the submit. DAMN!!! So I actually had two issues here the bad selector and the not able to add an attr to ie6/7, THX IC NOW, So are you suggesting I remove the text box and replace it with the same input with the id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.