0
나는보기 파일로 Pug를 사용했으며, 작업은 선택 드롭 다운에서 값을 선택한 다음 URL로 전달하는 것입니다. "/users? sortby = [object NodeList]"오류가 발생했습니다.url에서 선택한 값을 express js의 문자열로 표시하는 방법은 무엇입니까?
`
function onSorting(){
var sortby = document.getElementsByName('sorting');
window.location = "/users?sortby=" + sortby;
}
`
아래로 `
doctype html
html
head
script(type='text/javascript' src="/javascripts/script.js")
link(rel="stylesheet", href="/stylesheets/style.css")
h4=page_title
body
span Sort by
select(name = 'sorting' id = 'sort' onchange = 'onSorting()')
option(value = 'asc') Asc
option(value = 'desc') Desc
option(value = 'top 5') Top 5
option(value = 'bottom 5') Bottom 5
table#desc
tr
th ID
th Name
th Email
each users in userdetail
tr
td= users.id
td= users.name
td= users.email
html
`
내 script.js 원 아래로 흙 파일 소스를 찾아주세요 내가 가진 출력 URL은 아래와 같습니다. /users? sortby = [객체 NodeList]
제발 내가 도와 줄 사람을 제발 도와 줘.
시도'document.getElementsByName 수 [0] .value' 또는'에서는 window.location = "/ 사용자? sortby ="+ sortby [0] .value;'getElementsByName은 배열을 반환합니다. getElementById ('sort')를 사용하여'[0]' – DSCH
을 사용하지 않아도되며'window.location = "/ users? sortby ="+ sortby;를 사용하여 저에게 적합합니다. – Sugan