forms - deactivate two buttons until submit is clicked -


i need know how can deactivate 2 buttons until submit button clicked..i using javascript code deactivate 2 not work.

here form:

<form name="receta" id="receta" method="post">     <div class="row-fluid grid">         <div class="span4">             <label><b>lugar: </b></label>             <input type="text" class="input-block-level" value="" name="lugar" />         </div>         <div class="span4">             <label><b>nombre : </b></label>             <input type="text" class="input-block-level" value="" name="nombre" />         </div>         <div class="span4">             <label><b>edad : </b></label>             <input type="text" class="span4" value="" name="edad" />         </div>     </div>     <div class="row-fluid grid">         <div class="span4">             <b>pr&oacute;xima cita : </b>             ejemplo: en 5 semanas &oacute; 30 d&iacute;as.....                 <input class="input-block-level" name="receta" maxlength="50" value="" />               </div>     </div> <div class="row-fluid grid">         <div class="span4">     <button class="btn btn-inverse" type="submit" name="enviar" id="boton1" onclick="boton(this)">          <i class="icon icon-save icon-white"></i>          <?php echo $translate->__('save prescription'); ?>     </button> </div> <div class="span4">     <a class="btn btn-primary" href="receta_edit.php" type="button" id="boton2" onclick="boton(this)" >         <i class="icon icon-edit icon-white"></i>          <?php echo $translate->__('edit previous prescription'); ?>     </a> </div> <div class="span4">     <a class="btn btn-info" href="imprecetahoy.php" type="button" id="boton2" target="popup" onclick="window.open(this.href, this.target, 'scrollbars=yes,toolbar=no,menubar=no,status=no,width=parent,height=parent'); return false;" onclick="boton(this)">     <i class=" icon-print icon-white"></i>     <?php echo $translate->__('view/print last prescription'); ?>     </a> </div> </div> </form>  

and javascript try use:

<script>     function boton (obj)     {         if(obj.value=='boton 1')         { document.getelementbyid('boton1').disabled="false";         }         if(obj.value=='boton 2')         { document.getelementbyid('boton2').disabled="true";         }     } </script> 

here script in jsfiddle :

http://jsfiddle.net/hdx8e/

i'm little confused question. script following:

  • if boton1 clicked, disable it.
  • if boton2 clicked, enabled it.

in other words, when click submit button, disable submit button. has nothing intent understand it.

forgive me; don't understand spanish. seems want following 2 elements deactivated until submit clicked (which boton1).

<a class="btn btn-primary" href="receta_edit.php"  id="boton2" onclick="boton(this)" >  <a class="btn btn-info" href="imprecetahoy.php" target="popup"      onclick="window.open(this.href, this.target, 'scrollbars=yes,toolbar=no,     menubar=no,status=no,width=parent,height=parent'); return false;"       id="boton2" onclick="boton(this)"> 

the problem here both of these links have same id (boton2). should rename them unique, , preferably more meaningful, such receta_edit_link , imprecetahoy_link.

then, can disable both of these when page loads , enable them when submit button clicked following:

<script>     function boton(obj) {         if(obj.value == 'boton1') {             document.getelementbyid('receta_edit_link').disabled='true';             document.getelementbyid('imprecetahoy_link').disabled='true';         }     } </script> 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -