doujiu3768 2014-02-04 10:36
浏览 108
已采纳

单击单选按钮提交表单并将信息发送到另一个文件

this is my php code and i want to make when i push Radio button to make the form id prov submit like i have the the input submit button value="Shko Live". So i want when i push radio button on or off to submit form and to send the information to action="intervista-csv.php" method="post". Can anyone please help me ? :) Thank you

<?php 
session_start(); /// initialize session 
include("../../passwords.php"); 
check_logged(); /// function checks if visitor is logged. If user is not logged the user is redirected to login.php page  
?>
<?php
    include ("../../includes/functions.php");    
    $pdo = new PDO('mysql:dbname=test;host=localhost', 'root', '',array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
    $results  = $pdo->query('SELECT * FROM  `intervista80` WHERE  `delete` <> 1 ORDER BY  `id` DESC LIMIT 5')->fetchAll(PDO::FETCH_ASSOC);
    if (isset($_POST['ruaj']) && !empty($_POST['ruaj'])) {
        $pdo = new PDO('mysql:dbname=test;host=localhost', 'root', '',array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
        $stmt = $pdo->prepare('INSERT INTO `intervista80` (`title`, `kronika`) VALUES (:title, :kronika)');
        $stmt->execute(array('title' => $_POST['title'], 'kronika' => $_POST['kronika']));
    header("Location: ".$_SERVER['PHP_SELF']."");
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Intervista 80 Panel</title>
<link rel="stylesheet" type="text/css" media="screen, projection, tv" href="../../css/style.css"/>
<script language="javascript" type="text/javascript">
function textCounter(field,cntfield,maxlimit) {
    if (field.value.length > maxlimit) // if too long...trim it!
        field.value = field.value.substring(0, maxlimit);
    // otherwise, update 'characters left' counter
    else
        cntfield.value = maxlimit - field.value.length;
    }

function submitForm(formID) {
    document.getElementById(formID).submit();
    }

function setWTF(elementClicked) {
    if (elementClicked.value == 'Shto') {
        document.getElementById('wtf').value = 1;
    } else {
        document.getElementById('wtf').value = 2;
    }
}

</script>
</head>
    <div class="centered">
        <div class="wrapper">
            <form action="intervista-list.php" method="post" name="boto" target="_self" id="vendi">
<center>
            <a class="minimallive" href="intervista-nentitull-list.php" target="_self" />Live Nentitull</a>
            <a class="minimalshto" href="intervista-nentitull-shto.php" target="_self" />Shto Nentitull</a>
            <a class="minimallive" href="intervista-list.php" target="_self" />Live Titu/Kro</a>
            <a class="minimalshto" href="intervista-shto.php" target="_self" />Shto Titu/Kro</a>
            <a class="minimalmain" href="../../index.php" target="_self" />Main</a>

            <br /><br /><br />
            <a class="ndryshoblu" href="../../socket/scriptingintervista.php?id=11" target="_self" />Ndrysho Nentitull</a>
</center>   
            </form>
            <form action="#.php" method="POST" name="olform" target="_self" class="login" accept-charset="utf-8">
                <table>
                    <tr>
                    <td id="separator">
                        <input readonly="readonly" value="52" id="readonly" name="rem2" />
                        <label id="remaining">Karaktere te mbetura Titullin</label>
                    </td>
                    </tr>
                      <tr>
                        <td><textarea id="en-textarea" name="title" cols="52" rows="2" onkeydown="textCounter(this.form.title,this.form.rem,115);" onkeyup="textCounter(this.form.title,this.form.rem2,52);"></textarea></td>
                      </tr>
                    <tr>
                    <td id="separator">
                        <input readonly="readonly" value="12" id="readonly" name="rem3" />
                        <label id="remaining">Karaktere te mbetura Kronika</label>
                    </td>
                    </tr>
                      <tr>
                        <td><textarea id="en-textarea" name="kronika" cols="52" rows="2" onkeydown="textCounter(this.form.kronika,this.form.rem,115);" onkeyup="textCounter(this.form.kronika,this.form.rem3,12);"></textarea></td>
                      </tr>
                    <tr>
                    <td><input type="submit" name="ruaj" value="Ruaj"  /></td>
                    </tr>
                </table>
            </form>
            <form id="prov" action="intervista-csv.php" method="post" name="submit">                       
               <table>
                 <tr>
                   <th style="color:#900;">Titull</th>
                   <th style="color:#900;">Kronika</th>
                   <th style="color:#900;">Live</th>
                 </tr>
                 <?php $i=0; foreach ($results as $result) : ?>
                 <tr>
                   <td style="width:1200px;">
                   <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['title'],ENT_NOQUOTES,'UTF-8');?>" />
                   <label style="font-size:16px;"><?php echo htmlspecialchars($result['title'],ENT_NOQUOTES,'UTF-8');?></label>
                   </td>
                   <td style="width:300px;">
                   <input type="hidden" name="id<?php echo $i; ?>" value="<?php echo $result['id'] ?>" />
                   <input type="hidden" name="kronika<?php echo $i;?>"value="<?php echo htmlspecialchars($result['kronika'],ENT_NOQUOTES,'UTF-8');?>" />
                   <label style="font-size:16px;"><?php echo htmlspecialchars($result['kronika'],ENT_NOQUOTES,'UTF-8');?></label>
                   </td>
                   <td style="width:300px">
                    <label><input type="radio" name="shfaq<?php echo $i; ?>" value="1" id="radiobuttonsondazh_0" <?php if($result['live']==1) echo 'checked'; ?> />Po</label>
                    <label><input type="radio" name="shfaq<?php echo $i; ?>" value="0" id="radiobuttonsondazh_1" <?php if($result['live']==0) echo 'checked'; ?> />Jo</label>            
                   </td>
                   <td style="width:250px">
                      <input type="checkbox" name="chk<?php echo $i; ?>" >Fshi
                   </td>
                  </tr>
                  <?php $i = $i+1;
                        endforeach;
                   ?>
                 </table>
                 <tr>
                   <td>&nbsp;</td>
                   <td>&nbsp;</td>
                   <td>&nbsp;</td>
                   <td><input style="margin-top:26px; margin-left:206px;" type="submit" name="submit" value="Shko Live"  /></td>
                 </tr>
                <input type="hidden" value="<?php echo $i = $i-1; ?>" name="saka" />              
            </form>
</div>
</div>
<body>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • dongxi3911 2014-02-04 10:52
    关注

    See http://api.jquery.com/change/ & http://api.jquery.com/jquery.ajax/ For example:

    $('#myradio').change(function(){
      // either
      $('#myform').submit();
      // or ajax
      var myform = $('#myform').serialize();
      $.ajax({
        url: "/mysubmit",
        type: "POST",
        data: myform
      });
    });`
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。
  • ¥15 抖音看过的视频,缓存在哪个文件