get value of input using javascript

I am trying to get value of input using js but it doesn't work. Where is my mistake?

Alert doesn't work.

<body>
   <form name="inputform" id="form1" action="html_form_action.asp" method="get" style="visibility:hidden">
      Email: <input type="text" name="email" ></input>
      <input type="button" value="Gönder" onclick="CreateU()"></input>
   </form>
</body>

js file:

var xmail="";
CreateU = function(){
  var xx = "";
  xmail=document.getElementById('email').value;
  alert(xmail);
  xx= myAddress + xmail + ans + tf;
  window.location.assign(xx);
}

您的电子邮件地址没有ID:

<input type="text" name="email" id="email" />

Add id to your "Email" input: <input type="text" name="email" id="email" ></input>

Have a look: http://jsfiddle.net/K8kp9/

Note that now you possibly see nothing because of style="visibility:hidden" at your form tag..

Have some reading: Difference between id and name attributes in HTML


电子邮件是一个名字,只需将'name'改为'id'^^

链接地址: http://www.djcxy.com/p/88052.html

上一篇: 简单的POST方法不起作用

下一篇: 使用javascript获取输入的值