0
私はPugをビューファイルとして使用しました。タスクはselectドロップダウンから値を選択し、それをurlに渡すことです。私はエラー "/users?sortby = [オブジェクト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