Hello i have an issue with an exercise with checkboxes in php. I know how to get the value of each checkbox but in this case the value should be aplying style to an input text. The code i have till now it's this:
<?php
$negrita = 'unchecked';
$cursiva = 'unchecked';
$subrayado = 'unchecked';
if (isset($_REQUEST['submit'])) {
if (isset($_POST['negrita'])){
echo "<p style='font-weight: bold'>" . $_POST['texto']. "</p>" ;
}
if (isset($_POST['cursiva'])){
echo "<p style='font-style: italic'>" . $_POST['texto']. "</p>" ;
}
if(isset($_POST['subrayado'])){
echo "<p style='text-decoration: underline'>" . $_POST['texto']. "</p>" ;
}
}
?>
<form action="ejercicio2_form.php" method="post">
<p>Introduce el texto a mostrar:
<input type="text" name="texto" value="<?php if (isset($_REQUEST["texto"])) echo $_POST['texto'];?>" size="20"> <br />
</p>
Estilo del texto:
<input type="checkbox" name="negrita" <?php if (isset($_POST['negrita']) && $_POST['negrita']=="negrita") echo "checked";?> value="negrita"> Negrita
<input type="checkbox" name="cursiva" <?php if (isset($_POST['cursiva']) && $_POST['cursiva']=="cursiva") echo "checked";?> value="cursiva"> Cursiva
<input type="checkbox" name="subrayado" <?php if (isset($_POST['subrayado']) && $_POST['subrayado']=="subrayado") echo "checked";?> value="subrayado"> Subrayado <br />
<input type="submit" name="submit" value="Aceptar">
</form>
</body>
If in the text box i write "hello!" and then click all 3 checkboxes i get 3 different "hello!" one in bold another in italic and the third one underline. What i want is to get only one "hello!" with all the three text styles applyed.
Aucun commentaire:
Enregistrer un commentaire