Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Hidden Field not updating in form

Posted on 2015-02-06
Medium Priority
Last Modified: 2015-02-06
I was doing some testing and I can't figure out why my hidden field is not being populated? The value stays blank.
<!DOCTYPE html>
<html lang="en">
	function populateUser(){
		var currUser = "test@yopmail.com";
	    document.getElementById("txtUserName").value = currUser;
	    return true

  	<form action="www.somedomain.com" name="loginform" method="post" target="bottom">
	  <input type="hidden" id="txtUserName" name="txtUserName" value="" />
	  <input type="submit" name="submit" onsubmit="return populateUser()" value="start logon"/>

Open in new window

Question by:894359
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 44

Accepted Solution

Rainer Jeschor earned 2000 total points
ID: 40593111
please move the onsubmit to the form element and not in the submit button:
<form action="www.somedomain.com" onsubmit="return populateUser()" name="loginform" method="post" target="bottom">
	  <input type="hidden" id="txtUserName" name="txtUserName" value="" />
	  <input type="submit" name="submit"  value="start logon"/>

Open in new window


This should do the trick.

Author Comment

ID: 40594055
Not good working when you are tired! my bad! :0)

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question