我有一个 for
语句来创建 20 个表单,但在创建元素后,我的表单看起来像空(但上面有输入元素),这就是为什么我无法使用 POST 发送对象.
<form method="post" ></form>
这是我的代码:
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>
';
}
Ajax 会将输入元素放入上述代码的 div 中:
<div class="choosepart" id="c'.$i.'"></div>
如何调节它?
提前致谢
最佳答案
当您使用 ::
时,您正在尝试静态访问方法,因此您的函数签名应声明为: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
关于javascript - 带 for 语句的空表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31469069/