Pregunta

Hice un código en jquery y ajax trabajando muy bien en Safari, FF e IE8, pero no funciona en IE6.

Puede 5 grupos de formularios editables, que no deberían mostrarse, pero solo los primeros trabajos, el ajax tampoco funciona en IE6 e IE7.

centelleo solo se pone en 2, pero es 5, ¿cómo puede ver el siguiente enlace?

$(document).ready(function(){
 var n=1;           
    $forms = $('#MemberCont'+n+' form');
    $('#MemberCont'+n+' #toogle').hide();
 $('#MemberCont'+n+' #hide').hide();

$('#MemberCont'+n+' a').bind('click', function(){
        switch(this.id){
            case 'c':
    $('#MemberCont'+n+' #change').hide();
    $('#MemberCont'+n+' #phone').hide();
    $('#MemberCont'+n+' #hide').show();
                $('#MemberCont'+n+' #toogle').show(); 
                return false;
                break;
    case 'd':
    $('#MemberCont'+n+' #change').show();
    $('#MemberCont'+n+' #phone').show();
    $('#MemberCont'+n+' #hide').hide();
                $('#MemberCont'+n+' #toogle').hide(); 
                return false;
                break;
        }
    })

    $forms.bind('submit', function(){
        var $button = $('#MemberCont'+n+' button',this).attr('disabled',true);
        var params = $(this.elements).serialize();

        var self = this;
        $.ajax({
            type: 'POST',
            url: this.action,
            data: params,

  beforeSend: function(){
                $('#MemberCont'+n+' #phone').show();
    $('#MemberCont'+n+' #hide').hide();

                $('#MemberCont'+n+' #phone').html("Loading...");
            },
            success: function(txt){

    $('#MemberCont'+n+' #top').show();
                $('#MemberCont'+n+' #cadastro').hide ();
    $('#MemberCont'+n+' #hide').hide ();
    $('#MemberCont'+n+' #toogle').hide();
    $('#MemberCont'+n+' #change').show();

    $button.attr('disabled',false);

                $('#MemberCont'+n+' #phone').html(txt);

                self.reset();
            },

            error: function(txt){
                $('#MemberCont'+n+' #phone').html(txt);
            }
        })
        return false;
    });

});

$(document).ready(function(){
 var n=2;           
    $forms = $('#MemberCont'+n+' form');
    $('#MemberCont'+n+' #toogle').hide();
 $('#MemberCont'+n+' #hide').hide();

$('#MemberCont'+n+' a').bind('click', function(){
        switch(this.id){
            case 'c':
    $('#MemberCont'+n+' #change').hide();
    $('#MemberCont'+n+' #phone').hide();
    $('#MemberCont'+n+' #hide').show();
                $('#MemberCont'+n+' #toogle').show(); 
                return false;
                break;
    case 'd':
    $('#MemberCont'+n+' #change').show();
    $('#MemberCont'+n+' #phone').show();
    $('#MemberCont'+n+' #hide').hide();
                $('#MemberCont'+n+' #toogle').hide(); 
                return false;
                break;
        }
    })

    $forms.bind('submit', function(){
        var $button = $('#MemberCont'+n+' button',this).attr('disabled',true);
        var params = $(this.elements).serialize();

        var self = this;
        $.ajax({
            type: 'POST',
            url: this.action,
            data: params,

  beforeSend: function(){
                $('#MemberCont'+n+' #phone').show();
    $('#MemberCont'+n+' #hide').hide();

                $('#MemberCont'+n+' #phone').html("Loading...");
            },
            success: function(txt){

    $('#MemberCont'+n+' #top').show();
                $('#MemberCont'+n+' #cadastro').hide();
    $('#MemberCont'+n+' #hide').hide();
    $('#MemberCont'+n+' #toogle').hide();
    $('#MemberCont'+n+' #change').show();

    $button.attr('disabled',false);

                $('#MemberCont'+n+' #phone').html(txt);

                self.reset();
            },

            error: function(txt){
                $('#MemberCont'+n+' #phone').html(txt);
            }
        })
        return false;
    });
});

Html:

    <div id="MemberCont1" style="float:left; display:block; margin: 15px 30px 10px 30px; width: 563px;">
                    <div id="ResultTitle" style="width:217px;">Business Name</div>
                    <div id="MemberPhone" style="width:340px;"><div id="hide"><a href="" id="d"><img src="../img/hide_btn.gif" width="65" height="25" alt="Hide" /></a></div><div id="phone"><?php echo $result['business']; ?></div></div>
                  <hr class="Line" />
          <div id="toogle" style="font-size:12px; color:#FFF; ">
            <div id="none" style="position:relative; float:left; display:inline; padding-bottom:2px;">Change business name</div>
                  <form action="personal_update.php" style="clear:left; margin:0 0 10px 0;">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input name="dataform" type="text" class="FormMember" id="dataform" />
    <input name="id_member" type="hidden" value="<?php echo $result['id_member']; ?>" />
    <input name="table" type="hidden" value="business" /></td>
    <td align="right"><input name="submit" type="image" value="submit" src="../img/submit_member.gif" /></td>
  </tr>
</table>
           </form>
             </div><!--toogle-->
             <div id="change"><a href="" id="c"><img src="../img/change_btn.gif" alt="Change" width="64" height="25" align="left" /></a></div>
       </div><!--/*MemberCont*/-->

     <div id="MemberCont2" style="float:left; display:block; margin: 15px 30px 10px 30px; width: 563px;">
                    <div id="ResultTitle" style="width:217px;">Contact Name</div>
                    <div id="MemberPhone" style="width:340px;"><div id="hide"><a href="" id="d"><img src="../img/hide_btn.gif" width="65" height="25" alt="Hide" /></a></div><div id="phone"><?php echo $result['contact']; ?></div></div>
                  <hr class="Line" />
          <div id="toogle" style="font-size:12px; color:#FFF; ">
            <div id="none" style="position:relative; float:left; display:inline; padding-bottom:2px;">Change contact name</div>
                  <form action="personal_update.php" style="clear:left; margin:0 0 10px 0;">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input name="dataform" type="text" class="FormMember" id="dataform" />
    <input name="id_member" type="hidden" value="<?php echo $result['id_member']; ?>" />
    <input name="table" type="hidden" value="contact" /></td>
    <td align="right"><input name="submit" type="image" value="submit" src="../img/submit_member.gif" /></td>
  </tr>
</table>
           </form>
             </div><!--toogle-->
             <div id="change"><a href="" id="c"><img src="../img/change_btn.gif" alt="Change" width="64" height="25" align="left" /></a></div>
       </div><!--/*MemberCont*/-->
¿Fue útil?

Solución

Solo puede tener una ID en cualquier parte de su HTML. Intente usar clases en su lugar para las cosas que tiene que repetir.

Sospecho que, una vez que encuentran los primeros identificadores que estaba buscando, dejan de ocuparse de eso.

Aquí está la descripción del W3 de identificadores y clases.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top