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 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.

Profile

tzikeh: (Default)
tzikeh

August 2022

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930 31   

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 24th, 2026 09:44 pm
Powered by Dreamwidth Studios