What am I doing wrong?
<input type='text' name='keyword' id='keyword' size='16'>
<a href= "" onclick="window.open('.getElementById('keyword')');">
it opens a new window with without q = keyword.
What am I doing wrong?
<input type='text' name='keyword' id='keyword' size='16'>
<a href= "" onclick="window.open('http://scholar.google./scholar?q=document.getElementById('keyword')');">
it opens a new window with without q = keyword.
Share Improve this question edited Jul 10, 2012 at 19:56 LittleBobbyTables - Au Revoir 32.8k25 gold badges111 silver badges115 bronze badges asked Jul 10, 2012 at 19:55 campatskycampatsky 3241 gold badge3 silver badges14 bronze badges3 Answers
Reset to default 3You need to have document.getElementById('keyword')
as part of the code, not the hyperlink.
<input type='text' name='keyword' id='keyword' size='16'>
<a href= ""
onclick="window.open('http://scholar.google./scholar?q=' + document.getElementById('keyword') + '');">
You have the getElementById
enclosed in quotes.
It should be:
<a href="" onclick="window.open('http://scholar.google./scholar?q=' + document.getElementById('keyword').value);">
Declaring document.getElementById('keyword')
doesn't automatically give you the value written in it. For that, you need to do document.getElementById('keyword').value
.
What you probably want to do is this:
<a onclick="window.open('http://scholar.google./scholar?q=' + document.getElementById('keyword').value);">Click here</a>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745110134a4611798.html
评论列表(0条)