HTML form tag -- make one value equal another?

I'm trying to modify an HTML logon page for a product we use.  It asks for a username and a password (PIN).  The username and the password are the same thing, for everyone.  I want to make it so the user only has to type in their username, and have the form just use the same value for both "user" and "pass".  I don't really have access to edit anything else on the back end.  Is there any way to do this right within this page?  
<form action="/login" method="post"> 
<input type="hidden" name="url" value="^U" />

</b></td></tr><tr><td align="center" colspan=2><table border=0 

bgcolor="#669966" width=100% >

<tr><td align=right>Library Card Number: </td><td><input type="text" name="user" /><br /></td></tr>


<!-- <tr><td width=100% align=right>PIN: </b></td><td width=100%><input type="password" name="pass" /><br /></td></tr> -->

</table></td></tr> 
<tr>
  <td width=100% align=right>
    <div align="right">
      <input type="submit" value="Login" />
  </div></td><td align=left> 

</form>

Open in new window

LVL 1
mgudites1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurvinder Pal SinghCommented:
replace this line
<input type="text" name="user" />

by
<input type="text" name="user" onblur="this.form.pass=this.value"/>

and this line
<input type="password" name="pass"  style='display:none'/>
mgudites1Author Commented:
Thanks, but that's not working...am I literally entering "this.form.pass=this.value" or am I supposed to replace that with something?  This is what I have now.
<form action="/login" method="post"> 
<input type="hidden" name="url" value="^U" />

</b></td></tr><tr><td align="center" colspan=2><table border=0 

bgcolor="#669966" width=100%>

<tr><td align=right>
Library Card Number: </td><td><input type="text" name="user" onblur="this.form.pass=this.value"/>
<br/></td></tr>

<input type="password" name="pass"  style='display:none'/><br />

</table></td></tr> 
<tr>
  <td width=100% align=right>
    <div align="right">
      <input type="submit" value="Login" />
  </div></td><td align=left> 

</form>

Open in new window

Gurvinder Pal SinghCommented:
<<but that's not workin>>
when you say this, what do you actually mean?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

mgudites1Author Commented:
I mean I hit submit, and it tells me I wasn't successfully authenticated.  I get the same page that I would have got if the password field were actually visable, and I had left it blank or typed in a bad password.
quarky42Commented:
The smallest modification to the existing page I can think of off-hand is adding a little bit of Javascript, if that is allowed in your environment.

You can add an onclick= javascript function to the Submit button that would set the value of password equal to the value of user.


Add the part from <script> ending with </noscript> to the <head> section of your HTML.  (See the code snippet below)

Then change:

<input type="submit" value="Login" />

to:

<input type="submit" value="Login" onclick="setPassword()"/>


Then change:

<input type="password" name="pass" />

to:

<input type="hidden" name="pass" />


(The password field won't be shown, but it will still be part of the form.


<script>
function setPassword() {  // This function retrieves the username and stores it in the password form value too.
  usernameText = document.getElementsByName('user').value
  document.getElementsByName('pass').value = usernameText;
}
</script>
<noscript>You must use a browser that supports JavaScript and have it enabled!</noscript>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gurvinder Pal SinghCommented:
So, it is not passing the same user name and password on the server? please confirm this on the server side.

you can try replace the onblur with onkeyup
quarky42Commented:
This might be clearer if I just post the whole thing...the HTML given in the example above needs a little more tweaking than I first noticed.   You had the password field commented out completely...instead it needs to just be a hidden field like in the example below  (please adapt it as needed....I didn't have your whole html page to work with, so I threw in some tags to show the relative positioning of the script, head, body, etc.

See below::
<html>
<head>
<script>
function setPassword() {  // This function retrieves the username and stores it in the password form value too.
  usernameText = document.getElementsByName('user').value
  document.getElementsByName('pass').value = usernameText;
}
</script>
<noscript>You must use a browser that supports JavaScript and have it enabled!</noscript>
</head>

<body>

<form action="/login" method="post"> 
<input type="hidden" name="url" value="^U" />

</b></td></tr><tr><td align="center" colspan=2><table border=0 

bgcolor="#669966" width=100% >

<tr><td align=right>Library Card Number: </td><td><input type="text" name="user" /><br />
<input type="hidden" name="pass" />
</td></tr>
</table></td></tr> 
<tr>
  <td width=100% align=right>
    <div align="right">
      <input type="submit" value="Login" onclick="setPassword()"/>
  </div></td><td align=left> 

</form>
</body>
</html>

Open in new window

mgudites1Author Commented:
Thanks Quarky -- not working quite yet but I'll be it's something simple.  Here's everything I have in the page -- I think it matches yours:

gurvinder372 -- I have no idea how to check what you're looking for on the server side.

<html>
<head>

<script>
function setPassword() {  // This function retrieves the username and stores it in the password form value too.
  usernameText = document.getElementsByName('user').value
  document.getElementsByName('pass').value = usernameText;
}
</script>


<TITLE>Remote Student and Faculty Authentication</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
<!--
body {
	background-color: #FBF9CE;
}
-->
</style>
</head>
<body>


<form action="/login" method="post"> 
<input type="hidden" name="url" value="^U" />

</b></td></tr><tr><td align="center" colspan=2><table border=0 

bgcolor="#669966" width=100% >

<tr><td align=right>Library Card Number: </td><td><input type="text" name="user" /><br />
<input type="hidden" name="pass" />
</td></tr>
</table></td></tr> 
<tr>
  <td width=100% align=right>
    <div align="right">
      <input type="submit" value="Login" onclick="setPassword()"/>
  </div></td><td align=left> 

</form>

</body>
</html>

Open in new window

Gurvinder Pal SinghCommented:
try

<script>
  function setPasswordAndSubmit(form)
  {
     form.pass = form.user;
     form.submit();
  }
</script>
<form action="/login" method="post">
<input type="hidden" name="url" value="^U" />

</b></td></tr><tr><td align="center" colspan=2><table border=0

bgcolor="#669966" width=100%>

<tr><td align=right>
Library Card Number: </td><td><input type="text" name="user"/>
<br/></td></tr>

<input type="password" name="pass"  style='display:none'/><br />

</table></td></tr>
<tr>
  <td width=100% align=right>
    <div align="right">
      <input type="button" value="Login" onclick='setPasswordAndSubmit(this.form)' />
  </div></td><td align=left>

</form>
mgudites1Author Commented:
gurviner -- when I use that one, I hit login and nothing happens..no response at all.
quarky42Commented:
Why does it say action="/login"  ?     is login the name of a valid script?

Another option:   Instead of OnClick on the input button, you could use onblur on the user field itself....

Literally move the onlick="" statement to the user input field instead and rename onclick to onblur


onblur is triggered when the element loses focus.
Gurvinder Pal SinghCommented:
are you trying to say that when you use the two textboxes (user and pass), then your code works but using the code that i had suggestged, it doesn't?

mgudites1Author Commented:
Well, after all that, the people I was doing this for decided they didn't need it after all.  Thanks for your help, guys.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.