Solved

attr name in IE 11 appears as SubmitName

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Scroll 5 news at a time. 4 33
PHP and JQuery Syntax question 4 26
jQuery force form POST 7 48
googleapis - jQuery.com and so forth 3 14
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)

831 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