ฝากผู้เชี่ยวชาญด้านการเขียนเว็ปหน่อยค่า

เราใช้การเขียน สริปต์ ตรงbody อะค่ะ กะว่าจะ พอเลือก1อันให้มันเข้า conditions ใด condition นึงอะค่ะ

มันมี4 type เวลาเลือกก็ต้องเลือก type ใด type นึงแล้วทีนี้เขียน ให้มันเข้า conditions ไม่เป็นอะค่ะ
พอจะทราบไหมคะว่า เขียน conditions  อย่างไรดี if อะค่ะ ตรงที่ ขีดเส้นใต้ไว้ อะค่ะ หรือว่ามีตรงไหนผิดก็บอกได้นะคะ



<script>
                    document.write("<select name='items' onchange='searchType(this.value)'>");
                        document.write("<option>Select type:</option>");
                        document.write("<option name='name' id='name' value='name' >Item's Name</option>");
                        document.write("<option name='description' id='description' value='description' >Description</option>");
                        document.write("<option name='brand' id='brand' value='brand'>Brand</option>");
                        document.write("<option name='price' id='price' value='price'>Price</option>");
                    document.write("</select>");




if(document.getElementById("name").innerHTML = "name"){
                    document.write("<td><input name='item_head' type='text' id='item_head' /></td>");
                    document.write("<td><input name='search_head' type='button' id='search_head' value='search' onclick='searchHead(item_head.value)' /></td></tr>");
                    document.write("<tr><td>Body</td><td><input name='item_body' type='text' id='item_body' />");
                    document.write("<td><input name='search_body' type='button' id='search_body' value='search' onclick=' searchBody(item_body.value)' /></td></tr>")
                    document.write("<tr><td>Shoe</td><td><input name='item_shoes' type='text' id='item_shoes' />");
                    document.write("<td><input name='search_shoes' type='button' id='search_shoes' value='search' onclick=' searchShoes(item_shoes.value)' /></td>");
                } else if(document.getElementById("description").innerHTML = "description"){
                    document.write("<td><input name='des_head' type='text' id='des_head' /></td>");
                    document.write("<td><input name='search_head' type='button' id='search_head' value='search' onclick='searchDes(des_head.value)' /></td></tr>");
                    document.write("<tr><td>Body</td><td><input name='des_body' type='text' id='des_body' />");
                    document.write("<td><input name='search_body' type='button' id='search_body' value='search' onclick=' searchBody(des_body.value)' /></td></tr>")
                    document.write("<tr><td>Shoe</td><td><input name='des_shoes' type='text' id='des_shoes' />");
                    document.write("<td><input name='search_shoes' type='button' id='search_shoes' value='search' onclick=' searchShoes(des_shoes.value)' /></td>");
                } else if(document.getElementById("price").innerHTML = "price"){
                    ......
                } else if (document.getElementById("brand").innerHTML = "brand"){
                    ......
                }

ขอบคุณล่วงหน้านะคะ ^^

แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่