点击按钮无法获得单选按钮值

时间:2015-02-23 06:48:11

标签: html

我的桌子的每一行都有单选按钮。单击单选按钮并单击提交按钮时,所选值必须出现在对话框中。

我的代码是:

<form action="" method="POST">

            <table border="1" id="escalationTable" >

                <thead>
                    <tr>
                        <td style="width: 20px;"></td>
                        <td><h3>Date<h3></td>
                        <td><h3>Status<h3></td>
                        <td><h3>Ward<h3></td>
                        <td><h3>Source Address<h3></td>
                        <td><h3>Escalated by MPW on<h3></td>
                        <td><h3>Action to be taken<h3></td>
                        </tr>
                </thead>
                <tbody>
                    <?php for($i=$start;$i<$end;$i++)
                    {   
                    $address=$ARRAY[$i]['source_address'];
                    $add=str_replace('"',"'",$address);
                    $wardd=$ARRAY[$i]['ward_name'];
                    $typo=$ARRAY[$i]['type_desc'];
                    $action=$ARRAY[$i]['action_required'];
                    $Reptime = date('d-m-Y',strtotime($ARRAY[$i]['source_repTime']));
                    $category=$ARRAY[$i]['scat_desc'];
                    $subtype_s=$ARRAY[$i]['subtype_desc'];
                    $credai_s=$ARRAY[$i]['source_credai'];
                    $floor=$ARRAY[$i]['source_floorNo'];
                    $breed_s=$ARRAY[$i]['source_breedingSite'];
                    $recc_s=$ARRAY[$i]['source_recurrence'];
                    $closedate = date('d-m-Y',strtotime($ARRAY[$i]['action_closeDate']));
                    $statuss=$ARRAY[$i]['escl_status'];
                    $source_id=$ARRAY[$i]['source_id'];
                    $escl_id=$ARRAY[$i]['escl_id'];
                    $comma="(!@!)";
                    $tot1=$add.$comma.$wardd.$comma.$typo.$comma.$action.$comma.$Reptime.$comma.$category.$comma;
                    $tot2=$subtype_s.$comma.$credai_s.$comma.$floor.$comma.$breed_s.$comma.$recc_s.$comma.$closedate.$comma.$statuss.$comma.$source_id.$comma.$escl_id;
                    $total=$tot1.$tot2;

                    ?><tr>
                        <td><input type="radio" name="ID[]" value="<?php echo $total; ?>" <?php echo $_POST['ID'][0]==$total ? 'checked':'';?> required /></td>
                        <?php
                        $dmydate = date('d-m-Y',strtotime($ARRAY[$i]['escl_date']));
                        echo'<td>'.$dmydate.'</td>';
                        echo'<td>'.$ARRAY[$i]['escl_status'].'</td>';
                        echo'<td>'.$ARRAY[$i]['ward_name'].'</td>';
                        echo'<td>'.$ARRAY[$i]['source_address'].'</td>';
                        echo'<td>'.$ARRAY[$i]['source_escMPW_Date'].'</td>';
                        echo'<td>'.$ARRAY[$i]['action_required'].'</td>';
                        ?>  

                      </tr>
                      <?php }?>

                </tbody>
            </table>

            <div id="RecordNo">
            <?php echo"<p id='messages'>$records:$match</p>";?>
            </div>
            <table id="escButtons">
            <tr>
            <td>
            <input type="submit" name="details" value="Details" id="btndetails"   />
            </td>
            </tr>
            </table>
            <?php
            if(isset($_POST['details']))
            {
                $n=$_POST['ID'];

                $a=implode("</br>",$n);
                echo"</br>";
                list($add, $ward,$typo,$action,$Reptime,$category,$subtype_s,$credai_s,$floor,$breed_s,$recc_s,$closedate) = explode("(!@!)", $a);

                $address=str_replace("'",'"',$add);
                if($breed_s=='1')
                {$breed_s="Yes";}
                else{$breed_s="No";}

                if($recc_s=='1')
                {$recc_s="Yes";}
                else{$recc_s="No";}


                ?><div id="element_to_pop_up">
                <a class="b-close">x<a/>
                <table id="RowDetails">
                <tr>
                <td>
                <ul><?php echo"<b>Source reported date:</b>$Reptime</br>";?></ul>
                <ul><?php echo"<b>Source Address:</b>$address</br>";?></ul>
                <ul><?php echo"<b>Source Category:</b>$category</br>";?></ul>
                <ul><?php echo"<b>Source Type:</b>$typo</br>";?></ul>
                <ul><?php echo"<b>Source Subtype:</b>$subtype_s</br>";?></ul>
                <ul><?php echo"<b>Source CREDAI:</b>$credai_s</br>";?></ul>
                <ul><?php echo"<b>Source Floor No :</b>$floor</br>";?></ul>
                <ul><?php echo"<b>Breeding site:</b>$breed_s</br>";?></ul>
                <ul><?php echo"<b>Recurrence:</b>$recc_s</br>";?></ul>
                <ul><?php echo"<b>Source Action Required:</b>$action</br>";?></ul>
                <ul><?php echo"<b>Suggested Closure Date:</b>$closedate</br>";?></ul>
                </td>
                </tr>
                </table></div><?php
            }

我需要我的控制流程点击收音机 - >点击详细信息按钮 - >弹出单选按钮详细信息。请帮帮我!

2 个答案:

答案 0 :(得分:1)

首先你没有任何表单提交动作意味着你在任何地方提交表单就是你从post获取任何值的原因。如果你不想重新加载页面,你可以使用jquery来设置弹出窗口的值。 Fiddle

第二个在单选按钮中放置必填字段,只需要在一个单选按钮中放置。Source

这样做

<form id="myform">
<p> 
    Untraced :<input type="radio" name="inc_untraced"  value="No" required  />No
     <input type="radio" name="inc_untraced" value="Yes"  />Yes
</p>
<input type="submit" name="details" value="Details" id="my-button"   />
</form>
<!-- Element to pop up -->
<div id="element_to_pop_up">
    <a class="b-close">x<a/>
   U have clicked on <?php  $_POST['inc_untraced'];?>
</div>

Fiddle

答案 1 :(得分:0)

     (function($) {
            $(function() {

                // Binding a click event
                // From jQuery v.1.7.0 use .on() instead of .bind()
                $('#my-button').bind('click', function(e) {

                    // Prevents the default action to be triggered. 
                    e.preventDefault();
                     if($('input:radio:checked')){
                        var v = $('input:radio:checked').val();
                         if(v!=undefined){
                            $('.radioVal').text(v)
                        }else{
                            alert('please select radio button')
                            return false;
                        };

                      }
                    // Triggering bPopup when click event is fired
                    $('#element_to_pop_up').bPopup();

                });

            });

        })(jQuery);

<p> 
    Untraced :<input type="radio" name="inc_untraced"  value="No" required  />No
     <input type="radio" name="inc_untraced" value="Yes" required />Yes
</p>
<input type="submit" name="details" value="Details" id="my-button"   />

<!-- Element to pop up -->
<div id="element_to_pop_up">
    <a class="b-close">x<a/>
   U have clicked on <span class="radioVal"> </span> <?php  $_POST['inc_untraced'];?>
</div>
相关问题