试图将表单从html文件发布到php文件 [英] Trying to POST a form from html file to php file

查看:79
本文介绍了试图将表单从html文件发布到php文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我有这个工作,但由于某种原因,它不是将表格从Checkbox.html发布到table.php。当我在POST周围添加isset并且它没有进入isset if语句时,我想通了。我没有使用isset获得未定义的索引。我需要table.php中的整个复选框表单,这样我才能从一个非常长的复选框列表中得到我需要的东西。



当我运行它时,我开始在table.php然后按一个按钮,它会转到checkbox.html。我检查一些方框并按下提交按钮,它应该将表格发送回table.php。



这是checkbox.html:



I thought I had this working but for some reason it's not POSTing the form from Checkbox.html to table.php. I figured it out when I added isset around the POST and it's not getting into the isset if statement. I had been getting an undefined index without isset. I need the whole checkbox form in table.php so I can get what I need from what will be a really long checkBox list.

When I run this, I start in table.php then press a button and it goes to checkbox.html. I check some boxes and press the submit button and it's supposed to send the form back to table.php.

This is checkbox.html:

<!DOCTYPE html>
<!--

I am child window.
-->
<html>
    
    <head>
        <title>jQuery Michele Project</title>
        <link href="css/skins/polaris/polaris.css" rel="stylesheet">
        <link href="css/skins/all.css" rel="stylesheet">
        <link href="css/demo/css/custom.css" rel="stylesheet">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script type="text/javascript" src="js/jquery-1.11.0.js"></script>
        <script type="text/javascript" src="js/jquery.ui.core.js"></script>
        <script type="text/javascript" src="js/jquery.ui.widget.js"></script>
        <script src="js/icheck.js"></script>
                
        <script type="text/javascript">
            $(document).ready(function(){
                $('.input').iCheck({
                    checkboxClass:'icheckbox_polaris',
                    radioClass:'iradio_polaris',
                    increaseArea:'10%'
                });
            });
        </script>
    
        <style type="text/css">
            ul {list-style-type: none}
            img {padding-right: 20px; float:left}
            #infolist {width:500px}
        </style>
    </head>
    <body>
//************************************form***********
    <form id="myCheckboxForm" name="wholeForm" action="table.php" method="POST">
    <div class="skin skin-line">
        <div class="arrows">
          <div class="top" data-to="skin-flat"></div>
          <div class="bottom" data-to="skin-polaris"></div>
        </div>

      </div>
      <div class="skin skin-polaris">
        <div class="arrows">
          <div class="top" data-to="skin-line"></div>
          <div class="bottom" data-to="skin-futurico"></div>
        </div>
        <h3>Select Items for Column Headings</h3>
        <dl class="clear">
          <dd class="selected">
            <div class="skin-section">
              <h4>Live</h4>
              <ul class="list">
              
                <li>
                  <input tabindex="21" type="checkbox" name="ckboxList[]" id="Ckbox1">
                  <label for="polaris-checkbox-1">Checkbox 1</label>
                </li>
                <li>
                  <input tabindex="22" type="checkbox" name="ckboxList[]" id="Ckbox2" checked>
                  <label for="polaris-checkbox-2">Checkbox 2</label>
                </li>
                <li>
                  <input type="checkbox" name="ckboxList[]" id="Ckbox3" >
                  <label for="polaris-checkbox-3">Checkbox 3</label>
                </li>
                <li>
                  <input type="checkbox" name="ckboxList[]" id="Ckbox4" checked >
                  <label for="polaris-checkbox-4">Checkbox 4</label>
                </li>
                
            </div>
            
            <script>
            $(document).ready(function(){
              $('.skin-polaris input').iCheck({
                checkboxClass: 'icheckbox_polaris',
                radioClass: 'iradio_polaris',
                increaseArea: '20%'
              });
            });
            </script>
                     
          </dd>

        </dl>
        
      </div>
     
      <div>
//******submit button*******************************************
          <input type="submit" class="but" name="submit" id="submit" value="Update Table">   

      </div>
   
    </form>

    </body>
</html>





这是来自table.php:





This is from table.php:

<body>
    <div class="form">
        <p>
            <label>CheckboxList: Happy Friday 
//***************post*******looks like myCheckboxForm is empty**************
                <?php
                    if (isset ($_POST["myCheckboxForm"])) { //also tried wholeForm here
                         
                       $theFrm = ($_POST["myCheckboxForm"]); //also tried wholeForm here
                       alert("form:" + $theFrm); //this doesn't get hit 
                    }
                 ?>
                <script> getSelectedChbox($theFrm); </script>
            </label>
        </p>
    </div>
<table id="tableone" border="1">
    <thead>
    	<tr><th class="col1">Header 1</th><th class="col2">Header 2</th><th class="col3">Header 3</th><th class="col3">Header 4</th></tr>
    </thead>
    <tr class="del">
        <td contenteditable="false">Row 0 Column 0</td>
        <td><button class="editbtn">Edit</button></td>
        <td contenteditable="false">Row 0 Column 1</td>
        <td contenteditable="false">Row 0 Column 2</td>
    </tr>
    <tr class="del">
        <td contenteditable="false">Row 1 Column 0</td>
        <td><button class="editbtn">Edit</button></td>
        <td contenteditable="false">Row 1 Column 1</td>
        <td contenteditable="false">Row 1 Column 2</td>
    </tr>
    <tr class="del">
        <td contenteditable="false">Row 2 Column 0</td>
        <td><button class="editbtn">Edit</button></td>
        <td contenteditable="false">Row 2 Column 1</td>
        <td contenteditable="false">Row 2 Column 2</td>
    </tr>
    <tr class="del">
        <td contenteditable="false">Row 3 Column 0</td>
        <td><button class="editbtn">Edit</button></td>
        <td contenteditable="false">Row 3 Column 1</td>
        <td contenteditable="false">Row 3 Column 2</td>
    </tr>
     <tr class="del">
        <td contenteditable="false">Row 4 Column 0</td>
        <td><button class="editbtn">Edit</button></td>
        <td contenteditable="false">Row 4 Column 1</td>
        <td contenteditable="false">Row 4 Column 2</td>
    </tr>
     <tr class="del">
        <td contenteditable="false">Row 5 Column 0</td>
        <td><button class="editbtn">Edit</button></td>
        <td contenteditable="false">Row 5 Column 1</td>
        <td contenteditable="false">Row 5 Column 2</td>
    </tr>
</table>
    <input id="btnHide" type="button" value="Hide Column 2"/>
    <input id="chgColumns" type="button" value="Change Columns Displayed"
            önclick="return btn_changeColumns_onClick()" />
</body>





我一直在寻找的有用链接是:



HTML5初学者指南& CSS3 - 带有HTML5的强大表格 [ ^ ]



HTML5初学者指南& CSS3 - 服务器端故事 [ ^ ]



http://coursesweb.net/javascript/get-value-selected-checkboxes_cs [ ^ ]



Helpful links I've been looking at are:

Beginner's Guide to HTML5 & CSS3 - Formidable Forms with HTML5[^]

Beginner's Guide to HTML5 & CSS3 - Server Side Story[^]

http://coursesweb.net/javascript/get-value-selected-checkboxes_cs[^]

推荐答案

document ) .ready( function (){
(document).ready(function(){


' .input')。iCheck({
checkboxClass:' icheckbox_polaris'
radioClass:' iradio_polaris'
increa seArea:' 10%'
});
});
< / script>

< style type = text / css>
ul {list-style-type:none}
img {padding-right:20px; float :left}
#infolist {width:500px}
< / style >
< / head >
< body>
// ******************** ****************表格***********
< form id = myCheckboxForm name = wholeForm action = table.php method = POST>
< div = 皮肤-line>
< div class = arrows >
< div class = top data-to = skin-flat> </div>
<div class=\"bottom\" data-to=< span class=\"code-string\">\"
skin-polaris\"></div>
</div>

</div>
<div class=\"skin skin-polaris\">
<div class=\"arrows\">
<div class=\"top\" data-to=\"skin-line\"></div>
<div class=\"bottom\" data-to=\"skin-futurico\"></div>
</div>
<h3>Select Items for Column Headings</h3>
<dl class=\"clear\">
<dd class=\"selected\">
<div class=\"skin-section\">
<h4>Live</h4>
<ul class=\"list\">

<li>
<input tabindex=\"21\" type=\"checkbox\" name=\"ckboxList[]\" id=\"Ckbox1\">
<label for=\"polaris-checkbox-1\">Checkbox 1</label>
</li>
<li>
<input tabindex=\"22\" type=\"checkbox\" name=\"ckboxList[]\" id=\"Ckbox2\" checked>
<label for=\"polaris-checkbox-2\">Checkbox 2</label>
</li>
<li>
<input type=\"checkbox\" name=\"ckboxList[]\" id=\"Ckbox3\" >
<label for=\"polaris-checkbox-3\">Checkbox 3</label>
</li>
<li>
<input type=\"checkbox\" name=\"ckboxList[]\" id=\"Ckbox4\" checked >
<label for=\"polaris-checkbox-4\">Checkbox 4</label>
</li>

</div>

<script>
('.input').iCheck({ checkboxClass:'icheckbox_polaris', radioClass:'iradio_polaris', increaseArea:'10%' }); }); </script> <style type="text/css"> ul {list-style-type: none} img {padding-right: 20px; float:left} #infolist {width:500px} </style> </head> <body> //************************************form*********** <form id="myCheckboxForm" name="wholeForm" action="table.php" method="POST"> <div class="skin skin-line"> <div class="arrows"> <div class="top" data-to="skin-flat"></div> <div class="bottom" data-to="skin-polaris"></div> </div> </div> <div class="skin skin-polaris"> <div class="arrows"> <div class="top" data-to="skin-line"></div> <div class="bottom" data-to="skin-futurico"></div> </div> <h3>Select Items for Column Headings</h3> <dl class="clear"> <dd class="selected"> <div class="skin-section"> <h4>Live</h4> <ul class="list"> <li> <input tabindex="21" type="checkbox" name="ckboxList[]" id="Ckbox1"> <label for="polaris-checkbox-1">Checkbox 1</label> </li> <li> <input tabindex="22" type="checkbox" name="ckboxList[]" id="Ckbox2" checked> <label for="polaris-checkbox-2">Checkbox 2</label> </li> <li> <input type="checkbox" name="ckboxList[]" id="Ckbox3" > <label for="polaris-checkbox-3">Checkbox 3</label> </li> <li> <input type="checkbox" name="ckboxList[]" id="Ckbox4" checked > <label for="polaris-checkbox-4">Checkbox 4</label> </li> </div> <script>


(document).ready(function(){
(document).ready(function(){


这篇关于试图将表单从html文件发布到php文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆