Solved

attr name in IE 11 appears as SubmitName

Posted on 2013-12-18
3
907 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

734 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