[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5075
  • Last Modified:

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
0
Mark Steggles
Asked:
Mark Steggles
2 Solutions
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now