I've done some research on the subject and found that Safari does indeed support getElementById but I'm having issues with it and can't figure out why.
I have a page with various payment options and I want the appropriate radio button to be checked off in they click in a corresponding text box. This is what I have in my html page (it's a snippet of what's on the actual page)
and the javascript functions are as follows:Code:<form id="form1" name="form1" method="POST"> <input type="radio" id="PaymentMethod" name="PaymentMethod" value="CardOnFile">Use a Credit Card on file<br> Last 4 digits on card:<input type="text" onClick="MoveFocus();" id="Last4Digits" name="Last4Digits" maxlength="4" value="test" size="4"> <br> <input type="radio" name="PaymentMethod" id="PaymentMethod" value="BankTransfer">Use Bank Transfer<br> <input id="PaymentMethod" name="PaymentMethod" type="radio" value="credit" checked>Use the following credit card <select onClick="SettheFocus();" id="CardType" name="CardType" width="198"> <option>Select Card</option> </select> </form>
The code will work in in FF and IE6/7 but not in Safari. I can useCode:function SettheFocus() { form1.PaymentMethod[form1.PaymentMethod.length-1].checked=true; } function MoveFocus() { document.getElementById("PaymentMethod")(0).checked=true; }
but I've had some issues in the past using that so I prefer to use getElementById. getElementsByName will work in Safari but I don't understand why getElementById doesn't seem to be.Code:form1.PaymentMethod[0].checked=true;
It's probably something uber simple I'm missing but I can't seem to figure it out.


Reply With Quote
I spent quite a while this morning trying to find out what the problem was and googling it but not coming back with anything.

Bookmarks