Mary
Mary

Reputation: 1595

form submit by clicking on anchor tag in IE11

I am trying to update some old code that works correctly on all versions of IE except IE11. When an anchor tag is clicked a javascript function is run. The function . All that the function does is that it gets certain values from the DOM and then submits a form using the post action. I understand that IE11 submit does not work if the input element does not have a name. Here, the submit is done by clicking on an anchor tag- I tried adding a name and id to the anchor tag but it is still not working. Any idea on how to get it to work. Following is the anchor tag.

<a class="nohigh"  href="javascript:getClassDetails('<%=Id%>');">

Following is the javascript function:

function getClassDetails(a){
 var classId = document.getElementById(classIdRow ).value;
 var courseId = document.getElementById(courseIdRow).value;
 document.getElementById('val1').value = classId 
 document.getElementById('val2').value = courseId 
 document.getElementById('clasCourseForm').submit();
}

Upvotes: 0

Views: 327

Answers (3)

Mary
Mary

Reputation: 1595

fixed it - by adding both a name and id to the form.

Upvotes: 0

Simba
Simba

Reputation: 5032

[edit: removed the original answer, as the question has been changed to correct the syntax]

In addition, the JS code has other weirdness, in that the function is accepting a parameter (a) but never uses it within the function. There's almost certainly some kind of logic mistake involved there which you'll want to look into.

Upvotes: 1

ddavison
ddavison

Reputation: 29042

The function that you want should be:

function getClassDetails(a){
 var classId = document.getElementById(classIdRow).value; // assuming classIdRow is defined
 var courseId = document.getElementById(courseIdRow).value; // assuming courseIdRow is defined
 document.getElementById('val1').value = classId;
 document.getElementById('val2').value = courseId;
 document.getElementById('clasCourseForm').submit();
}

That's at least assuming that all the JavaScript you have up there ^ is verbatim.

Upvotes: 1

Related Questions