tzikeh: (headache)
[personal profile] tzikeh
I'm trying to figure out how to make a form field entry become a hidden input value. Anyone who knows anything about html forms and a little cgi, please read:
I have a form which includes the following hidden input value:

<INPUT name="mailfrom" type="hidden" value="Network Chicago - Contact Form">

So that when the form data is submitted, the "from" in the email says "Network Chicago - Contact Form".

What I would *like* the "from" to be is the person's email - which they are putting into the form itself in a field defined thusly -

<INPUT name="email" type="text" size="30">

I would like to somehow make this:

<INPUT name="mailfrom" type="hidden" value="xxx">

where "xxx" equals the value input to the "email" form field.

If anyone can figure this out and can explain it to me - PLEASE HELP.

Many, many thanks.

Date: 2003-08-19 10:38 am (UTC)
From: [identity profile] tanacawyr.livejournal.com
Me thinkee there must be some javascript shit that will do this ... hm ... *mulling*

Date: 2003-08-19 10:39 am (UTC)
From: [identity profile] tzikeh.livejournal.com
Yeah, my thought was javascript too - but I can't figure it out. It might be because I have no brain left, but...

Date: 2003-08-19 10:46 am (UTC)
From: [identity profile] taraljc.livejournal.com
eeep! I sorta kinda know how to do it using VB Script, but that only works if you are creating an ActiveServer page...

Try javascript.internet.com? You might be able to find the answer there...

Date: 2003-08-19 10:48 am (UTC)
From: [identity profile] barkley.livejournal.com
It's been a while since I've done javascript and it was only brief at that...

Anyway I think you can just assign it to a variable and then put that in the value for the mailfrom field
/********************************************/

var EMAILVALUE = TheForm.email.value

<input ... >

Date: 2003-08-19 10:52 am (UTC)
From: [identity profile] barkley.livejournal.com
And you really shouldn't take advice from someone who forgets how to make things in tags's appear. *g*

But the second line was this:
INPUT name="mailfrom" type="hidden" value="% =EMAILVALUE %"


Date: 2003-08-19 10:57 am (UTC)
From: [identity profile] tzikeh.livejournal.com
LOLOL -

actually, do you have any chatting capabilities - AIM, irc, anything? I'd like to go through this step by step with you like the big dork I am.

Do you have a few minutes?

Date: 2003-08-19 11:01 am (UTC)
From: [identity profile] barkley.livejournal.com
I do have a few minutes, but I'm at work, and I don't/can't have any chat software here.

Date: 2003-08-19 11:07 am (UTC)
From: [identity profile] tzikeh.livejournal.com
ok - drop me a line at tzikeh at thechicagoloop dot net.

Date: 2003-08-19 10:58 am (UTC)
From: [identity profile] barkley.livejournal.com
Of course that's with opening bracket before the first percent sign and closing one after the second.

And of course the ones that encloses that line too. *g*

Date: 2003-08-19 11:31 am (UTC)
nomadicwriter: [Doctor Doom] Victor Von Crankypants (Default)
From: [personal profile] nomadicwriter
Does the form use a "submit" button? Because if so, I'd think the simplest thing would be to add a quick line of Javascript to the html code for the button (assuming your form is called "form"):

onClick="form.mailfrom.value=form.email.value;"

If for whatever reason you can't trigger it via a button, you could put it inside the code for the email field, so the mailfrom value is updated as soon as that field loses focus:

<INPUT name="email" type="text" size="30" onBlur="form.mailfrom.value=this.value;" >

Date: 2003-08-19 11:38 am (UTC)
From: [identity profile] tzikeh.livejournal.com
We do trigger with a submit button - I'll try that script - thanks - will let you know if it works!

Date: 2003-08-19 11:40 am (UTC)
From: [identity profile] tzikeh.livejournal.com
My current submit button code looks like this:

<A href="javascript:document.form1.submit()"><IMG src="/images/submitform.gif" border="0" width="90" height="20">

where should I put your bit of script?

Date: 2003-08-19 11:48 am (UTC)
nomadicwriter: [Doctor Doom] Victor Von Crankypants (Default)
From: [personal profile] nomadicwriter
I'd think it would go after the "javascript:" declaration but before the submit statement, with a semi-colon to separate the two. Like this:

<A href="javascript: form1.mailfrom.value=form1.email.value; document.form1.submit()">

Date: 2003-08-19 12:17 pm (UTC)
From: [identity profile] tzikeh.livejournal.com
ok - this is goofy, but here's my next question

using this script, the email "from" field comes in as

From: Value defined in hidden field <"emailfield@email.com">

and when hitting reply, the "to" in the reply is "Value defined in hidden field" and doesn't actually go the email address.

Does any of that make sense, and how do I solve it?

Date: 2003-08-19 01:11 pm (UTC)
nomadicwriter: [Doctor Doom] Victor Von Crankypants (Default)
From: [personal profile] nomadicwriter
Ack. I'm really not sure why it's doing that. It seems to be passing the whole thing as an object instead of just the value, but I can't see why. At this point in my own code, I generally start hacking things around madly until something works.

Um. Things that might or might not help at all...

I'm not sure it would make a difference, but maybe it would help if where I've said to use "form1.mailfrom.value=form1.email.value" you make each of those "document.form1" - I don't think that's the problem, but maybe it's not finding the objects properly without the complete address.

You could try splitting it into two statements so there's a temporary variable in the middle instead of directly assigning one value to another. Something like:

<A href="javascript:
   var temp=form1.email.value;
   form1.mailfrom.value=temp;
   document.form1.submit()">


Sometimes Javascript throws funny turns about things like that.

If it's still not working, I'd suggest put in a couple of alert boxes before and after executing the statement to try and see what's happening:

<A href="javascript:
   alert(form1.email.value);
   form1.mailfrom.value=form1.email.value;
   alert(form1.mailform.value);
   document.form1.submit()">


See if the alert boxes come up with the actual values you want to be assigned, or if they come up with something like "[object]" or whatever bizarre message you're getting instead.

Hmm. Maybe I'll fiddle around with some Javascript and see if I can figure out what's going on there.

Date: 2003-08-19 05:54 pm (UTC)
prillalar: (yo ho)
From: [personal profile] prillalar
If you haven't already got this working...

What cgi script are you using? Is it custom or is it just FormMail? The script name should be in the <form> tag. If it's FormMail, that's pretty customizable and I could go through the docs to see what's what.

Actually, have you tried leaving out the hidden mail-from field altogether? It might then default to simply using the email value.
Page generated Feb. 24th, 2026 10:21 am
Powered by Dreamwidth Studios