Solved

attr name in IE 11 appears as SubmitName

Posted on 2013-12-18
3
839 Views
Last Modified: 2013-12-18
Hi folks,

I know it has been talked a lot on this issue but I need some info on how get rid of it. I've a form in which I've the possibility to add additional inputs through jquery by doing some cloning. Afterwards, I just do an attr on name but as mentioned on the topic name, it replaces it as SubmitName. So basically, I can't retrieve after submitting the form, all the values inside inputs which have name replaced by submitName.

here is a sample of my code:

    
        $('.addInfo').click(function() {
            var copy = $('#Info').clone(true,true);
            var formId = 'Info' + window.uniqueLeg;
            copy.attr('id', formId );
            copy.removeAttr('style');
            copy.find(':input#tripdate').each(function() {
                $(this).addClass('datepicker');
                var dateid = 'tripdate' + window.uniqueLeg;
                $(this).attr('id', dateid );
                $(this).attr('name', $(this).attr('name')+window.uniqueLeg );
                $(this).datepicker({ dateFormat: "dd/mm/yy" });
            });
            copy.find(':input#routingdep').each(function() {
                $(this).addClass('aptsearch');
                var dateid = 'routingdep' + window.uniqueLeg;
                $(this).attr('id', dateid );
                $(this).attr('name', $(this).attr('name')+window.uniqueLeg );
                $(this).autocomplete({source:'suggest_apt.php', minLength:3});
            });
          ....

Open in new window



So I've googled and find out several pages talking about it and giving as resolution to use the createElement(), html() or use javascript innerHTML. But I wasn't able to make them work on such code.
http://msdn.microsoft.com/en-us/library/ms534184.aspx
https://forum.jquery.com/topic/set-name-parameter-does-not-work-in-ie7
http://felipenmoura.org/articles/bug-on-ie-when-creating-elements-with-name-submitname
http://api.jquery.com/html/

What would you suggest to solve this issue? Use another browser than IE is not a solution :(
Regards
David
0
Comment
Question by:David_Pazos
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39727244
But why do you need to clone if you're changing the ID, the name, add(set?) a class, attach autocomplete or datepicker ?

Anyway, try this to see if that make you happy (this is for the second field) :
            var $field = $(':input#routingdep', copy);
            $fiedl = $field.replaceWith("<input type='" + field.attr("type") + "' id='routingdep " + window.uniqueLeg + "' name='" + field.attr("name") + window.uniqueLeg + "' class='aptsearch " + field.attr("class") + "' />");
            $fiedl.autocomplete({source:'suggest_apt.php', minLength:3});

Open in new window

0
 

Author Comment

by:David_Pazos
ID: 39727309
Thanks for your comment. In fact, I'm cloning as I want to give the option to add and remove items. Besides that, there are a lot of fields, see below a sample :

    <div id="trip">
    <TABLE id="Info" style="display:none" width="400px" border="0">
          <TR >
            <TD ><INPUT type="checkbox" class="delCheckLeg" name="chk"/></TD>
              <TD ><INPUT type="text" id="tripdate" name="tripdate"></TD>
            <TD ><INPUT type="text" name="deptime[]"/></TD>
              <TD ><INPUT type="text" id="routingdep" name="routingdep"/></TD>
              <TD ><INPUT type="text" id="routingarr" name="routingarr"/></TD>
              <TD ><INPUT type="text" name="fttime[]"/></TD>
              <TD ><INPUT type="text" name="pax[]"/></TD>
          </TR>
    </TABLE>
    </div>

Open in new window


Thanks a lot for your suggestion, I'll try it immediatelly. I keep you posted :)
0
 

Author Comment

by:David_Pazos
ID: 39727346
Worked like a charm!!!

thanks a lot!

this is the latest version. I had issue with the class in the replaceWith


$(this).replaceWith("<input type='" + $(this).attr("type") + "' id='routingdep" + window.uniqueLeg + "' name='" + $(this).attr("name") + window.uniqueLeg + " />");
$(this).addClass('aptsearch');
$(this).autocomplete({source:'suggest_apt.php', minLength:3});

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now