Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

attr name in IE 11 appears as SubmitName

Posted on 2013-12-18
3
Medium Priority
?
998 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 83

Accepted Solution

by:
leakim971 earned 2000 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

926 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