How to use input radio with input hidden

0

I want to record two fields of a table simultaneously, it would be the field "gale_photos" and "gale_status" and I'm using the code below, but it only writes the "gale_status" field to No.

How do I enter the SIM in the "gale_status" field when I click on the SIM option.

    <div align="center" style=" padding:2px; border-right:solid 1px;float:left; width:210px; height:auto; float:left;">
    <?php
    include '../conexao.php';
    $codigo = $_POST['codigo'];
    $gale_fotos = $_POST['gale_fotos'];
    $gale_status = $_POST['gale_status'];

    $query = mysql_query("SELECT * FROM menu");
    $res = mysql_fetch_array($query);

    if(isset($_POST['gale'])){

    $gale_fotos = $_POST['gale_fotos'];
    $gale_status = $_POST['gale_status'];
    $update = mysql_query("UPDATE menu SET gale_fotos = '$gale_fotos', gale_status = '$gale_status'");

    if($update == ''){
    echo "<script language='javascript'>
    window.alert('Erro ao Habilitar Link Galeria de Fotos!');
    </script>";
    }else{
    echo "<meta http-equiv='refresh' content='0; URL= menu_halitar_link.php'>
    <script language='javascript'>
    window.alert('Link Galeria de Fotos Habilitado com sucesso!');
    </script>";
    }}?>

    <form name="gale" action="" method="POST" enctype="multipart/form-data">
    <label>Habilitar o Link Galeria de Fotos?</label><br /><br />

    <label>Sim</label>
    <input type='radio' name='gale_fotos' value='<li><a href="<?php echo $res['dominio'];?>galeria.php" class="nav1">Galeria de Fotos</a></li><li class="divider"></li>' />
    <input type='hidden' name='gale_status' value='Sim' /><br />

    <label>Não</label>
    <input type="radio" name="gale_fotos" value="" />
    <input type="hidden" name="gale_status" value="Não" /><br />
    <input type="submit" name="gale" value="Atualizar" />
    </form>
    </div>

Thank you in advance for your attention.

    
asked by anonymous 23.10.2015 / 22:25

1 answer

0

I made an implementation today for checkbox, but that also works for what you need with radio, take a look:

HTML:

<input id="chkCamp1" name="rad" type="radio" data-check="1" value="elemento 1"> elemento 1
<input id="chkCamp2" name="rad" type="radio" data-check="2" value="elemento 2"> elemento 2
<input type="text" data-view>
<input type="hidden" data-hide>

And JavaScript:

$(function() {
    $('[data-check]').on('click', function() {
        var myInput = {valor: $(this).val(), id: $(this).data('check')};
        $('[data-view]').val(myInput.valor);
        $('[data-hide]').val(myInput.valor);
    });
});

It's working: link

    
23.10.2015 / 22:32