I need to know how can I deactivate two buttons until the submit button is clicked.. I am using a Javascript code which deactivate the another two but not work.
Here is my 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óxima cita : </b>
Ejemplo: En 5 semanas ó 30 dí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 this is the Javascript I try to 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 is the script in jsfiddle :