2015-02-23 167 views
0

我的表中每行都有单选按钮。点击单选按钮并点击提交按钮选定的值必须出现在对话框中。单击按钮时无法获取单选按钮值

我的代码是:

<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="([email protected]!)"; 
        $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("([email protected]!)", $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 
      } 

我需要我的控制流程点击放射>单击详细信息按钮 - >与单选按钮的细节信息弹出。请帮帮我 !

回答

1

首先,你没有任何表单提交动作意味着你dint提交表单的任何地方是你dint得到任何价值post.If你不想重新加载页面的原因,你可以使用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

+0

“ü甲肝点击”不给的单选按钮值的消息.... – 2015-02-23 07:42:11

+0

@LillyShk如果你不想重新加载页面做http://jsfiddle.net/singhakash07/6pzbug1b/1/ – silentprogrammer 2015-02-23 07:45:17

+0

其实这是我的实际主要问题的一个样本,你可以帮我吗? – 2015-02-23 07:51:22

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> 
+0

选定的单选按钮值没有被张贴在弹出框中。 – 2015-02-23 07:43:14