Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript getElementById()赢得';行不通_Javascript_Html - Fatal编程技术网

Javascript getElementById()赢得';行不通

Javascript getElementById()赢得';行不通,javascript,html,Javascript,Html,我想在我的网站上插入一个基本表单,这样我的用户就可以搜索食谱了。我很难让javascript从表单中找到输入值。任何帮助都将不胜感激 <!DOCTYPE html> <html> <head> <script> function searchURL() { var foodSearch = window.open("http://search.myrecipes.com/search.html?N=17&mFil=false&

我想在我的网站上插入一个基本表单,这样我的用户就可以搜索食谱了。我很难让javascript从表单中找到输入值。任何帮助都将不胜感激

<!DOCTYPE html>
<html>
<head>
<script>
  function searchURL()
{
    var foodSearch =  window.open("http://search.myrecipes.com/search.html?N=17&mFil=false&Ntt=" + "document.getElementById("searchFood").value");

};
  </script>
  </head>

<body>

<form>

<fieldset>
<legend>Search for Healthy Diet Recipes</legend>
<p>
Type in the name of the Recipe or Healthy Diet Food you would like to cook below:<br>
</p>
<br>
<input type="text" id='searchFood' >
<input type="button" value="Find Delicious Food" onClick="searchURL()">

</fieldset>
</form>
</body>

</html>

函数searchURL()
{
var foodSearch=window.open(“http://search.myrecipes.com/search.html?N=17&mFil=false&Ntt=“+”document.getElementById(“searchFood”).value”);
};
搜索健康饮食食谱

在下面输入您想要烹饪的食谱或健康饮食食品的名称:


不要将其添加到
引号中

使用以下命令:

var foodSearch = window.open("http://search.myrecipes.com/search.html?N=17&mFil=false&Ntt=" + document.getElementById("searchFood").value);
不要将其添加到
引号中

使用以下命令:

var foodSearch = window.open("http://search.myrecipes.com/search.html?N=17&mFil=false&Ntt=" + document.getElementById("searchFood").value);

您是否查看了控制台中的错误?这将是一个很好的开始…您是否查看了控制台中的错误?那将是一个很好的起点。。