0

テーブルに値を挿入しようとしています。しかし、エラーが発生します:未定義のインデックス:13行目のC:\ wamp \ www \ cdij\insert.phpのtext_unitcost

挿入ページは、すべての値が通過するページです。挿入ページは次のとおりです。

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script language="JavaScript" src="myminiAJAX.js"></script>
<script language="JavaScript" src="functions.js"></script>
</head>
<body>
To Insert a new part<br/>
<form name="insert_values" action="insert.php" method="post">
    Select The Category<select name="combo_category" id="combo_category" onChange="doAjax('fill_combo_insertpart_combo_assembly.php', 'combo_category='+getValue('combo_category'), 'populate_combo_insertpart_combo_assembly', 'post', '1')">
    <option value="-1">--Please Select--</option>
    <option value="Brake">Brake</option>
    <option value="Fastner">Fastner</option>
    <option value="Suspension">Suspension</option>
    <option value="-1">--Please Select--</option>
    <option value="-1">--Please Select--</option>
    <option value="-1">--Please Select--</option>
    <option value="-1">--Please Select--</option>
    <option value="-1">--Please Select--</option>
    </select><br/><br/>
    Select The Assembly<select name="combo_assembly" id="combo_assembly" onchange="doAjax('fill_combo_index_and_indexpart_combo_part.php', 'par='+getValue('combo_assembly'), 'populate_combo_index_and_insertpart_part', 'post', '1')">
    <option value="-1">--Please Select--</option>
    </select><br/><br/>
    Select The Part:<select name="combo_part" id="combo_part">
    <option value="-1">--Please Select--</option>
    </select><br/><br/>
    Where Do you want to Insert?<br/><br/>
    Material<input type="radio" name="radio_insert_table" value="material" onclick="create_form_insertpart_material();doAjax('fill_combo_indexpart_combo_material.php','','populate_combo_insertpart_combo_material','post','1')"/>
    Process<input type="radio" name="radio_insert_table" value="process" onclick="create_form_insertpart_process();doAjax('fill_combo_indexpart_combo_process.php', '', 'populate_combo_insertpart_combo_process', 'post', '1');doAjax('fill_combo_indexpart_combo_multiplier.php', '','populate_combo_insertpart_combo_multiplier', 'post', '1')" />
    Fastner<input type="radio" name="radio_insert_table" value="fastner"/>

    <div id="form" ></div>
    <br/><br/>
    <input type="submit" name="ipsubmit" value="Submit"/>
</form>
</body>
</html>

" <div id="form">"では、javascriptを使用したラジオボタンの選択に基づいて、いくつかの新しいフィールドが作成されます。コードは次のとおりです。

function create_form_insertpart_process() {
    document.getElementById("form").innerHTML="<select name=\"combo_process\" id=\"combo_process\" onChange=\"doAjax('fill_combo_indexpart_combo_process.php','process_name='+getValue('combo_process'),'populate_textbox_insertpart_process_unticost_and_unit','post','1')\"><option value=\"-1\">--Please Select--</option></select><br/><br/> ";
    document.getElementById("form").innerHTML+="<input type=\"text\" name=\"text_use\" id=\"text_use\" />";
    document.getElementById("form").innerHTML+="<input type=\"text\" name=\"text_unitcost\" id=\"text_unitcost\" disabled=\"disabled\" />";
    document.getElementById("form").innerHTML+="<input type=\"text\" name=\"text_unit\" id=\"text_unit\" disabled=\"disabled\" />";
    document.getElementById("form").innerHTML+="<input type=\"text\" name=\"text_quantity\" id=\"text_quantity\" />";
    document.getElementById("form").innerHTML+="<select name=\"combo_multiplier\" id=\"combo_multiplier\" onChange=\"doAjax('fill_combo_indexpart_combo_multiplier.php','multiplier_name='+getValue('combo_multiplier'),'populate_textbox_insertpart_multiplier_value','post','1')\"><option value=\"-1\">--Please Select--</option></select><br/><br/> ";
    document.getElementById("form").innerHTML+="<input type=\"text\" name=\"text_multipliervalue\" id=\"text_multipliervalue\" disabled=\"disabled\"/>";
    window.setInterval("calculate_textbox_insertpart_text_subtotal()",10);
    document.getElementById("form").innerHTML+="<input type=\"text\" name=\"text_subtotal\" id=\"text_subtotal\"  disabled=\"disabled\" />";

}

上記のコードでは:

document.getElementById("form").innerHTML+="<input type=\"text\" name=\"text_unitcost\" id=\"text_unitcost\" disabled=\"disabled\" />";

このフィールドの値は、AJAXとXMLを使用してサーバーからデータベースを返すjavascript関数によって生成されます

そして最後に、データベースに値を挿入するコードを書いているページがあります

<?php
    include("dbconfig.inc.php");
     $combo_category=$_POST['combo_category'];
     $combo_assembly=$_POST['combo_assembly'];
     $combo_part=$_POST['combo_part'];
     $radio_insert_table=$_POST['radio_insert_table'];
     if($radio_insert_table=="material") {

     }
     else if($radio_insert_table=="process") {
        $combo_process=$_POST['combo_process'];
        $text_use=$_POST['text_use'];
        $text_unitcost=$_POST['text_unitcost'];
        //$text_unit=$_POST['text_unit'];
        //$text_quantity=$_POST['text_quantity'];
        //$combo_multiplier=$_POST['combo_multiplier'];
        //$text_multipliervalue=$_POST['text_multipliervalue'];
        ////$text_subtotal=$_POST['text_subtotal'];
        $select=$dbh->prepare('INSERT INTO process (process_unitcost) values(:text_unitcost)');
        //$select->execute(array(':text_unitcost' => $text_unitcost));

     }
?>

上記のコードでは、13行目で未定義のインデックスtext_unitcostとしてエラーが発生しています

助けてくれてありがとう

4

1 に答える 1

0

無効で値のないINPUTフィールドを投稿すると、投稿されないため、それらにインデックスが設定されません。

無効なフィールドは投稿されませんreadonly="readonly"。表示したいが編集を許可しない場合に使用する必要があります。

参照http://www.w3.org/TR/html4/interact/forms.html#h-17.12

于 2013-03-06T12:27:03.710 に答える