空表单与声明

时间:2015-07-17 05:43:24

标签: javascript php ajax forms for-loop

我有一个 (?<=at\s)\d{3,5}\s\S*\s\w*.*(?=,) 语句来创建20个表单,但在创建元素后,我的表单看起来像空(但我有输入元素),这就是我不能用POST发送对象的原因。

for

这是我的代码:

<form method="post" ></form>

Ajax会将输入元素放在上面代码的div中:

for($i= 1 ; $i<=$numtest ; $i++){
        $mdata = $numtoword->ToWordFa($i);
        echo '
            <li>
                <div class="questitle2 noselect"><a href="#">عنوان سوال '.$mdata.'</a></div>
                <div class="quescontent">
                    <input type="text" class="questitle byekan" name="tt'.$i.'" id ="tt'.$i.'" placeholder="عنوان سوال '.$i.'" onclick="select()" /><br/>
                    <div style="text-align:right;margin-top:10px;" class="qkind">نوع سوال :
                                <input type="radio" name="istest'.$i.'" id="is2test'.$i.'" value="yt2" onclick="add_choice(\'c'.$i.'\' , \'yt2\');" /><label for="is2test'.$i.'"><span class="noselect fade"> 2 گزینه ای</span></label>
                                <input type="radio" name="istest'.$i.'" id="is4test'.$i.'" value="yt4" onclick="add_choice(\'c'.$i.'\' , \'yt4\');" /><label for="is4test'.$i.'"><span class="noselect fade"> 4 گزینه ای</span></label>
                                <input type="radio" name="istest'.$i.'" id="nottest'.$i.'" value="nt2" onclick="add_choice(\'c'.$i.'\' , \'nt2\');"/><label for="nottest'.$i.'"><span class="noselect fade"> تـشریحی</span></label>
                    </div> 
                    <form method="post" >
                        <input type="hidden" name="tid1" value="'.$tkey.'"/>
                        <input type="hidden" name="thisquestion1" value="'.$i.'"/>
                        <div class="choosepart" id="c'.$i.'"></div>
                        <div id="res"> </div>
                        <input class="fade" id="sc'.$i.'" style="margin-top:5px;" type="button" name="Send" onclick="formget( this.form  , \'tests.php\' , \'res\' , \'dd\' ,\''.$i.'\');" value="ثبت این سوال" disabled/>
                    </form>
                </div>
            </li>
        ';
    }

怎么能缓和呢?

提前致谢

2 个答案:

答案 0 :(得分:2)

当您使用::时,您尝试静态访问某个方法,因此您的函数签名应声明为:public static function toWord2()

我认为您将方法toWord2定义为非静态方法,并且您尝试将其作为静态调用。那就是说。

1)如果要调用静态方法,则应使用::并将方法定义为静态。

// Defining a static method in a Foo class.
public static function toWord2() { /* code */ }

// Invoking that static method
NumericHelper::toWord2();

2)否则,如果您想要调用实例方法,则应该使用->实例化。

// Defining a non-static method in a Foo class.

    public function toWord2() { /* code */ }

    // Invoking that non-static method.
    $objNumericHelper = new NumericHelper();
    $objNumericHelper->toWord2();

你可以骑同样的东西about OOP & static methods in PHP

答案 1 :(得分:0)

请在for语句后面的代码下面,此代码将告诉您问题/错误的位置/位置。如果我们需要更多帮助,请告诉我。

//This code will suggest what/where is the error

print("<pre>");
print_r(error_get_last());
print("</pre>");

希望这会对你有所帮助。

谢谢!