表单提交后获取空的隐藏值

Getting empty hidden values after form submit

本文关键字:隐藏 获取 表单提交      更新时间:2023-09-26

我想在客户端存储一些数据,以便创建JavaScript代码,但在表单提交后,我得到了空的隐藏字段值。如何解决此问题?

fid = 1100124686694263;
user = Akshay Barpute;
document.getElementById('fid1').value = fid;
document.getElementById('user1').value = user;
Welcome Fill below information to setup your account</br>
<form action='fb1.php' method='post'>
  Enter your email:
  <input type='email' name='emailid'>
  </br>
  Select examination:
  <input type='radio' name='jungle' value='GRE'>GRE& nbsp;&nbsp;&nbsp;&nbsp;
  <input type='radio' name='jungle' value='GMAT'>GMAT&nbsp;&nbsp;&nbsp;&nbsp;
  <input type='radio' name='jungle' value='CAD'>CAD&nbsp;&nbsp;&nbsp;&nbsp;
  <input type='radio' name='jungle' value='MBA CET'>MBA CET&nbsp;&nbsp;&nbsp;&nbsp;
  <input type='radio' name='jungle' value='others'>others(includes bank & it company exams)
  <br>
  <input type='hidden' name='fid' id='fid1' value=''>
  <input type='hidden' name='user' id='user1' value=''>
  <input type='submit' name='sub' value='Submit'>
</form>

变量user需要一个字符串类型:

fid = 1100124686694263;
user = "Akshay Barpute";
document.getElementById('fid1').value = fid;
document.getElementById('user1').value = user;