提交单选按钮更改

时间:2014-02-01 13:47:16

标签: html radio-button

当我将单选按钮从开启更改为关闭或从关闭更改为开启时,如何进行提交。我的HTML代码是:)

<div class="centered3">
    <div class="wrapper">
        <form action="oralive-csv.php" method="post" name="fshi_shkruaj">
        <td><input style="margin-bottom:10px; float:right;" type="submit" name="submit" value="Shko Live" /></td>                          
        <table style="width:950px;">
             <tr>
               <th style="float:left;color:#900;">Titulli</th>
               <th style="color:#900;">Nentitulli</th>
               <th style="color:#900;">Live</th>
             </tr>
             <?php $i=0; foreach ($results as $result) : ?>
             <tr>
               <td style="padding-right:5px;height:1.5em;">
               <input type="hidden" name="id<?php echo $i; ?>"value="<?php echo $result['id'] ?>" />
               <input type="hidden" name="title<?php echo $i;?>"value="<?php echo htmlspecialchars($result['text'],ENT_NOQUOTES,'UTF-8');?>" />
               <div class="textndrysho"><input style="font-size:16px;color:#000;width:200px;" type="text" name="title<?php echo $i;?>" value="<?php echo htmlspecialchars($result['text'],ENT_NOQUOTES,'UTF-8'); ?>" maxlength="32"/>
               </td></div>
               <td style="padding-right:5px;height:1.5em;">
               <input type="hidden" name="id<?php echo $i; ?>"value="<?php echo $result['id'] ?>" />
               <input type="hidden" name="subtitle<?php echo $i;?>"value="<?php echo htmlspecialchars($result['subtext'],ENT_NOQUOTES,'UTF-8');?>" />
               <div class="textndrysho"><input style="font-size:16px;color:#000;width:400px;" type="text" name="subtitle<?php echo $i;?>" value="<?php echo htmlspecialchars($result['subtext'],ENT_NOQUOTES,'UTF-8'); ?>" maxlength="45"/>
               </td></div>
               <td style="padding-right:5px;height:1.5em;">
               <input type="hidden" name="id<?php echo $i; ?>"value="<?php echo $result['id'] ?>" />
               <input type="hidden" name="vendi<?php echo $i;?>"value="<?php echo htmlspecialchars($result['vendi'],ENT_NOQUOTES,'UTF-8');?>" />
               <div class="textndrysho"><input style="font-size:16px;color:#000;width:120px;" type="text" name="vendi<?php echo $i;?>" value="<?php echo htmlspecialchars($result['vendi'],ENT_NOQUOTES,'UTF-8'); ?>" maxlength="12"/>
               </td></div>
               <td>
                <label><input type="radio" name="shfaq<?php echo $i; ?>" value="1" id="radiobuttonsondazh_0" <?php if($result['live']==1) echo 'checked'; ?> onclick="document.getElementById('myForm').submit();" />Po</label>
                <label><input type="radio" name="shfaq<?php echo $i; ?>" value="0" id="radiobuttonsondazh_1" <?php if($result['live']==0) echo 'checked'; ?> onclick="document.getElementById('myForm').submit();" />Jo</label>            
               </td>
               <td>
                  <input type="checkbox" name="chk<?php echo $i; ?>" >Fshi
               </td>
              </tr>
              <?php $i = $i+1;
                    endforeach;
               ?>
             <tr>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
               <td><input style="margin-top:26px;" type="submit" name="submit" value="Shko Live"  /></td>
             </tr>
            </table>
            <input type="hidden" value="<?php echo $i = $i-1; ?>" name="saka" />              </form>
    </div>
</div></center>

我已经尝试过onChange提交此表格但不幸运。 :( 有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

您可能需要使用一些特殊的javascript,他们称之为事件处理程序。 onclick,blclick等。有一种方法可以将javascript和php代码混合在一起。也许这会奏效。另外,你希望这个表格能做什么,我可以更轻松地帮助你。

function dosomething()
{
var formelement = document.getElementById['theid'].value; //retrieves the value from the form element
if (formelement == "whatever")
  {
  window.open("http://www139.net63.net"); //opens a url in a window
  }
  else
  {
  alert("This is a popup window");
   }
}
====================
<input type="radio" name="whatever" id="theid" value="your value, url etc." onclick="dosomething()">
相关问题