第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

從表單生成輸出框

從表單生成輸出框

冉冉說 2022-07-21 11:02:34
<!DOCTYPE html><html><head><title>CT Traders</title><style>fieldset    {width:40%; margin:0px 0px 10px 1%;}legend      {padding:2px; text-indent:5px;}h2, p       {margin-left: 1%;} input[type="submit"], input[type="reset"]             {display:inline; float:none;}</style><script> //suggested logic for the validateInput() functionfunction validateInputs() {//check payment methodvar methodChecked = false;for (var i=0; i <document.frmCustOrders.class.length;i++){    if (document.frmCustOrders.class[i].checked ==true)    {        classChecked = true;        vClass = document.frmCustOrders.class[i].value;    }}//check customer index valuevar customerIndex = document.getElementById("customer").value;//retrieve order quantityvar qty = document.getElementById("qty").value;//validate form dataif (customerIndex == -1) //validate customer{    alert("Please select a customer.")    return false;}else if () //validate qty{}else if (fsClassChecked == false) //validate payment method{    alert("Please select a payment method.")    return false;}else //output{    orderEntries = customer+ "\n"+ qty+ "\n"+vClass;    alert(orderEntries);    return false;}}</script></head><body><h2>Customer Order</h2><form name="frmCustOrders" id="frmCustOrders"onsubmit="return validateInputs();" action=""><fieldset id="fsCustomer"><legend>Customer List</legend><select name="customer" id="customer" size="3">     <option>107 Paula Harris</option>    <option>232 Mitch Edwards</option>    <option>229 BTC</option></select></fieldset><p> <label for="qty">Order Quantity:&nbsp;&nbsp;&nbsp;</label><input type="text" name="qty" id="qty" /></p>我在獲取用于檢索表單上的選擇的輸出框時(shí)遇到問題。此外,在我的一個(gè) if 語句中,我被分配檢查該值是否在 1 到 999 之間,但我對(duì)此完全空白。我是編碼(Javascript)的新手,這是我的第一堂課。任何幫助使其工作的幫助將不勝感激。
查看完整描述

1 回答

?
12345678_0001

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊

你的代碼有一些問題


多余的else if ()


fsClassChecked變量未聲明。


迭代元素時(shí)的冗余類document.frmCustOrders.class


使用錯(cuò)誤的變量customer應(yīng)該是customerIndex


錯(cuò)誤的條件(customerIndex == -1)更改為(customerIndex == "")


//suggested logic for the validateInput() function

function validateInputs() 

{

//check payment method

var methodChecked = false;

var fsClassChecked = false;

for (var i=0; i <document.frmCustOrders.length;i++)

{

    if (document.frmCustOrders[i].checked ==true)

    {

        fsClassChecked = true;

        vClass = document.frmCustOrders[i].value;

    }


}


//check customer index value

var customerIndex = document.getElementById("customer").value;


//retrieve order quantity

var qty = document.getElementById("qty").value;


//validate form data

if (customerIndex == "") //validate customer

{

    alert("Please select a customer.")


    return false;

}

else if(qty == "" || qty < 1 || qty > 999){

alert("Please enter qty 1-999.")


    return false;

}

else if (fsClassChecked == false) //validate payment method

{

    alert("Please select a payment method.")

    return false;

}

else //output

{

    orderEntries = customerIndex + "\n"+ qty+ "\n"+vClass;

    alert(orderEntries);

    return false;

}


return false;

}

<!DOCTYPE html>

<html><head><title>CT Traders</title>

<style>

fieldset    {width:40%; margin:0px 0px 10px 1%;}

legend      {padding:2px; text-indent:5px;}

h2, p       {margin-left: 1%;} 

input[type="submit"], input[type="reset"] 

            {display:inline; float:none;}

</style>

<script>

 

</script>

</head>

<body>

<h2>Customer Order</h2>

<form name="frmCustOrders" id="frmCustOrders"

onsubmit="return validateInputs();" action="#">


<fieldset id="fsCustomer">

<legend>Customer List</legend>

<select name="customer" id="customer" size="3"> 

    <option>107 Paula Harris</option>

    <option>232 Mitch Edwards</option>

    <option>229 BTC</option>

</select>

</fieldset>


<p> 

<label for="qty">Order Quantity:&nbsp;&nbsp;&nbsp;</label>

<input type="text" name="qty" id="qty" />

</p>


<fieldset id="fsClass">

<legend>Payment Method</legend> 

<input type="radio" name="method" id="check" value="check" />

    &nbsp;&nbsp;Check<br /> 

<input type="radio" name="method" id="creditCard" value="credit card" />

    &nbsp;&nbsp;Credit Card<br />

<input type="radio" name="method" id="debitCard" value="debit card" />

    &nbsp;&nbsp;Debit Card

</fieldset>

<p> <input type="submit" value="Submit" />&nbsp;&nbsp;&nbsp;&nbsp;

<input type="reset" value="Reset" /></p>

</form>

</body>

</html>


查看完整回答
反對(duì) 回復(fù) 2022-07-21
  • 1 回答
  • 0 關(guān)注
  • 92 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)