このフォームを終了する前に最後の部分が1つありますが、テンプレートの機能は少し複雑になっています。基本的には、送信ボタンがそのコマンドを実行する前に「同意」チェックボックスが必要になります。PHPチェックボックス提出前の検証
$tbl->addRow();
$tbl->addCell($frm->addInput('checkbox', 'checkbox', 'check'),
'submit', 'data', array('colspan'=>4));
$tbl->addRow();
$tbl->addCell($frm->addInput('submit', 'submit', 'Submit'),
'submit', 'data', array('colspan'=>4, 'onclick'=>'if(!this.form.checkbox.checked)return false};',));
$frmStr = $frm->startForm('result.php', 'post', '', array('onsubmit'=>'return checkSubmit(this);')) .
$tbl->display() . $frm->endForm();
return $frmStr;
}
ここには投稿/チェックボックスのための私のPHPです。以下は、行/セル/入力を作成するために呼び出される関数です。この形式を使うと、単にタグをつけることができず、私はそれが私を抱きしめていると思います。
function addCell($data = '', $klass = '', $type = 'data', $attr_ar = array()) {
$cell = array(
'data' => $data,
'klass' => $klass,
'type' => $type,
'atts' => $attr_ar
);
if (empty($this->cur_section['rows'])) {
try {
throw new Exception('You need to addRow before you can addCell');
} catch(Exception $ex) {
$msg = $ex->getMessage();
echo "<p>Error: $msg</p>";
}
}
// add to current section's current row's list of cells
$count = count($this->cur_section['rows']);
$curRow = &$this->cur_section['rows'][$count-1];
$curRow['cells'][] = &$cell;
}
function addInput($type, $name, $value, $attr_ar = array()) {
$str = "<input type=\"$type\" name=\"$name\" value=\"$value\"";
if ($attr_ar) {
$str .= $this->addAttributes($attr_ar);
}
$str .= $this->xhtml? ' />': '>';
return $str;
}
これが役立つ場合は、より多くのコードを共有してください。誰でもaddInput関数内の "array"引数の内側に適切にコードを書式設定する手助けはできますか?
あなたはどのフレームワークを使用していますか? –
申し訳ありませんが、フレームワークはどういう意味ですか?ちょうどPHPのテンプレート私はいくつかのjsの機能とソース これは私があなたが何を意味しているかの建物です:http://www.dyn-web.com/php/order_form/example2.php – sixfiveoh
@sixfiveoh PHPフォームが提出される前に何もできません。 PHPはクライアントではなくサーバ上で動作します。 – Barmar