Click to See Complete Forum and Search --> : Need To Append Hidden Text


nihiser
11-12-2005, 06:05 AM
Hi. I'm curious to find out if there is an easy way to append hidden text when submitting via a form. For example:

I have a webmail form that requires the user to type in the entire email address as a username. However, since the domain for every user using the webmail is the same, I would like to automatically append the "@whateverdomain.com" to just their user.

Thankee.

BonRouge
11-12-2005, 06:15 AM
I guess you use some kind of server-side language to deal with the form. Just add that part to the username there.

balloonbuffoon
11-12-2005, 04:39 PM
You could use javascript, if you don't want the server sides scripts to deal with the user name. Here's an example:
<script type="text/javascript"> //this goes in your head
function append(formName) {
var domain = "whateverdomain.com"; //change to reflect your domain
var user = document.forms[formName].user.value; //change to reflect username form field name
var parts = user.split("@");
if (parts[1] != domain) {
document.forms[formName].user.value += "@" + domain; //change to reflect username form field name
}
document.forms[formName].submit();
}
</script>

<form name="login"> <!-- this is an example form -->
<input name="user"><input type="button" value="Submit" onClick="append('login')">
</form>


--Steve