Solved

attr name in IE 11 appears as SubmitName

Posted on 2013-12-18
3
888 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery + C#.net radiobuttonlist 3 45
Open dialog with server side controls in it 3 46
email validation 9 49
pass foreach data in php into jquery ajax 10 50
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
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…

733 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