request得到select多選的值

2021-05-08 10:55:47 字數 379 閱讀 2152

將select的multiple屬性的值設定為"multiple"時,select就能支援多選.

問題:如何用request得到select支援多選時的值?

例: multiple="multiple">

第乙個值

第二個值

第三個值

上面的select就能支援多選,當使用者選擇了全部,那麼得到全部值的方法:

string value = request.getparametervalues("test");

如果只是用 string value = request.getparameter("test"); 來獲得傳遞引數,那麼只能得到使用者選中的第乙個引數的值,如果選中的是後兩個,那麼value的值為"第二個值".

得到select所有option裡的值

1 取得所有的option個數 document.getelementbyid options.length 2 取得每個option的id值 document.getelementbyid options i value 3 取得每個option在頁面顯示的文字 document.geteleme...

Request 擴充套件

asp.net程式設計中,經常要傳遞引數,獲取引數 以get形式傳參為例,獲取引數時,要這樣寫 int id if request.querystring id null 首先判斷該引數是否存,然後獲取並轉為數值型。其實,即便如此,上面的 也是不夠安全的,例如,id等於空,或是非數字字元,都會出錯的...

request獲取路徑

從request物件中可以獲取各種路徑資訊,以下例子 假設請求的頁面是index.jsp,專案是webdemo,則在index.jsp中獲取有關request物件的各種路徑資訊如下 string path request.getcontextpath string basepath request....