onclick form submit does not work in Internet Explorer

Hello,

Due to some limited functionality, I am having to rebuild the page using ajax so I can add more features. I am having a problem getting an onclick form submit to work in Internet Explorer... it works fine in ff and opera. Here is the relevant code:

thirdRowCellLink.setAttribute("onclick", "this.parentNode.firstChild.checked = 'true';document.AltAccomConfirm.submit()");

thirdRowCellLink is the span in the following rendered html after my ajax has done its stuff:

<p style="border-bottom: 10px solid white; padding: 4px; background-color: rgb(225, 225, 225); text-align: right;"><input type="radio" value="000" id="000" name="Accom" style="display: none;"/><span onclick="this.parentNode.firstChild.checked = 'true';document.AltAccomConfirm.submit()" style="color: rgb(189, 16, 24); cursor: pointer;">Choose & continue</span></p>



Can anyone see why this wouldn't work?

Steggs
LVL 30
Mark StegglesWeb DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PhatzerCommented:
use an ID in the form, like 'AltAccomConfirmID' then try:

document.getElementById('AltAccomConfirmID').submit();

Instead. Worth a go.
0
Mark StegglesWeb DeveloperAuthor Commented:
Thanks but thats not it... it appears that the onclick doesnt work in ie at all :/
0
Mark StegglesWeb DeveloperAuthor Commented:
IE is not applying the onclick that i add in this line:

thirdRowCellLink.setAttribute("onClick", "alert('clicked');this.parentNode.firstChild.checked = 'true';document.getElementById('AltAccomConfirm').submit()");

I wonder if its because its ajax or something... Im gonna try using addEventListener instead

Steggs
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

hieloCommented:
Try either this:
function ref - no quote
thirdRowCellLink.setAttribute("onclick", function(){this.parentNode.firstChild.checked = 'true';document.AltAccomConfirm.submit();});
OR this function ref - with quote:
thirdRowCellLink.setAttribute("onclick", "function(){this.parentNode.firstChild.checked = 'true';document.AltAccomConfirm.submit();}");
0
LeeKowalkowskiCommented:
I reckon you might have a field with the name "submit".  Therefore form.submit refers to the field.  Is that it?

--
Lee
0
LeeKowalkowskiCommented:
Oops, I just read the rest of the thread, I don't think you can set event handlers using setAttribute at all.

It's either .onclick = function(){} - or a cross-browser addEventListener implementation.

--
Lee
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark StegglesWeb DeveloperAuthor Commented:
Hello,

your first one worked in IE but not FF... it works using the onclick instead of setattribute:

thirdRowCellLink.onclick = function(){this.parentNode.firstChild.checked = 'true';document.AltAccomConfirm.submit();};

Thanks foy your help

Steggs
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.