By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,948 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,948 IT Pros & Developers. It's quick & easy.

simple question: translate select values into a hidden text box

P: n/a
hello:

everybody! I have a simple question. How can I translate the selected
value
from art to recipient(hidden input button)?
<form name="send" method="post" action="send.cgi">
<select name="art" size="1" style=font-size:9pt onChange="Setvalue()">
<option value="ad2">ad</option>
<option value="editor2">editor</option>
<option value="club2">club</option>
<option value="reguser2">reguser</option>
<option value="webmaster2">webmaster</option>
<option value="event2">event</option>
</select>

<INPUT type=hidden value=REMOTE_HOST,HTTP_USER_AGENT,REMOTE_ADDR
name=env_report>
<INPUT type=hidden value="" name=recipient>
<INPUT type=hidden value=http://www.emkt.com.cn/survey/submit_kotter.shtml
name=redirect>

pls help me !

thanks!
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On 24 Feb 2004 02:13:02 -0800, calfliu <ca*****@21cn.com> wrote:
everybody! I have a simple question. How can I translate the selected
value from art to recipient (hidden input button)?
Why do you need to? Why not name the select element, recipient?

If you *need* to transfer the value between the controls, users with
JavaScript disabled will be unable to use the form. Consider the effects
of that carefully before you continue with this approach.

To answer your question, use the following:

var mailForm = document.forms[ 'send' ];
mailForm.recipient.value =
mailForm.art.options[ mailForm.art.selectedIndex ].value;

As for you HTML, you should *always* place attribute values in quotation
marks (single or double). For the form values in env_report, and redirect,
you *must* use quotation marks. The commas and slashes in each control,
respectively, produce invalid HTML without quotes.

The attributes currently lacking quotes in the HTML below are:

select: style
input (env_report): type, value, name
input (recipient): type, name
input (redirect): type, value, name
<form name="send" method="post" action="send.cgi">
<select name="art" size="1" style=font-size:9pt onChange="Setvalue()">
<option value="ad2">ad</option>
<option value="editor2">editor</option>
<option value="club2">club</option>
<option value="reguser2">reguser</option>
<option value="webmaster2">webmaster</option>
<option value="event2">event</option>
</select>

<INPUT type=hidden value=REMOTE_HOST,HTTP_USER_AGENT,REMOTE_ADDR
name=env_report>
<INPUT type=hidden value="" name=recipient>
<INPUT type=hidden
value=http://www.emkt.com.cn/survey/submit_kotter.shtml
name=redirect>


Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2

P: n/a
In article <op**************@news-text.blueyonder.co.uk>,
Michael Winter <M.******@blueyonder.co.invalid> wrote:
To answer your question, use the following:

var mailForm = document.forms[ 'send' ];
mailForm.recipient.value =
mailForm.art.options[ mailForm.art.selectedIndex ].value;

In addition, you need to invoke the above two lines. Add:

<form name="send" method="post" action="send.cgi"
onSubmit="adjustForm()">

in the <head> section place

<SCRIPT type="text/javascript">
function adjustForm {

var mailForm = document.forms[ 'send' ];
mailForm.recipient.value =
mailForm.art.options[ mailForm.art.selectedIndex ].value;

}
</script>

Robert
Jul 20 '05 #3

P: n/a
but it doesn't work. the send.cgi is just Formmail.cgi.when I submit
the form there display :
Error: Bad/No Recipient

There was no recipient or an invalid recipient specified in the data
sent to FormMail. Please make sure you have filled in the recipient
form field with an e-mail address that has been configured in
..................

you know the in the formmail. the recipent is :

Field: recipient
Description: This form field allows you to specify to whom you wish
for your form results to be mailed. Most likely you will want to
configure this option as a hidden form field with a value equal to
that of your e-mail address.

As of version 1.8, You can include multiple recipients by separating
the values with commas.
Syntax:
<input type=hidden name="recipient" value="em***@your.host.com"> OR
<input type=hidden name="recipient"
value="us**@yourhost.com,us***@yourhost.com">

so what shall I do. pls help
Jul 20 '05 #4

P: n/a
1) Check to see if you got some javascript error.
You have to turn on error reporting in IE.
In netscape, type in javascript on the command line

2) Put out on alert on the function to see the value of the email address:

<SCRIPT type="text/javascript">
function adjustForm {

var mailForm = document.forms[ 'send' ];
mailForm.recipient.value =
mailForm.art.options[ mailForm.art.selectedIndex ].value;

alert("recipient = " + mailForm.recipient.value );

}
</script>

Robert
Jul 20 '05 #5

P: n/a
[The post below is the reply to an e-mail sent by the OP. The return
address couldn't be found by my mail server, so I've replied here]

On Wed, 25 Feb 2004 10:38:30 +0800, Karl Liu <ca*****@21cn.com> wrote:
Mr Winter: thanks for your help! But it did not work according to
your code. I use the formmail.cgi. so the code is:
The snippet of code I provided does work. However, Robert's follow-up
introduced some syntax errors.

I've indicated corrections for both the script and your HTML below.
<html>
<head>
<title>*国营销**网 > 联系方法</title>
<meta http-equiv="Content-Type"
content="text/html; charset=gb2312">
<link rel="stylesheet" href="/doc-sys/emkt.css"
type="text/css" TITLE="EMKT">
<SCRIPT type="text/javascript">
function adjustForm {
The line above is where the problem lies. The function declaration is
missing the required parameter list. It should read:

function adjustForm() {

Please continue to read below.
var mailForm = document.forms[ 'send' ];
mailForm.recipient.value =
mailForm.art.options[ mailForm.art.selectedIndex ].value;
} </script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="4">
[snipped menu table and SSI include]
<TABLE border=0 cellPadding=3 cellSpacing=0 width="100%">
<TR>
<td>
<br><br>
<P class="title" align="center">联系方法</P>
<div class="11pt"><b>深圳市麦肯特企业顾问有 公司</b><br>
   电话:0755-26936136 (总机转)<br>
   *真:0755-26936158<br>
   地址:深圳市南山区华侨城汉 大厦2301室<br>
   邮编:518053<br>
<P align="center">
<a href="http://www.emkt.com.cn/intro/emkt_beijing.html"
>麦肯特北京公司</a>  <a href="http://www.emkt.com.cn/intro/emkt_shanghai.html"
>麦肯特上海公司</a> 

<a href="http://www.emkt.com.cn/intro/emkt_wuhan.html"
>麦肯特*汉公司</a>

</div>
</p>


The nesting here is incorrect. The closing P tag should appear before the
DIV tag:

</p>
</div>
<form name="send" method="post"
action="/cgi-sys/send.cgi" onSubmit="adjustForm()">
[snipped first table in form]
<P align=center>
<input type=hidden name="required" value="姓名,电*邮件">
<INPUT type=hidden value=REMOTE_HOST,HTTP_USER_AGENT,REMOTE_ADDR
name=env_report>
<INPUT type=hidden name=redirect
value=http://www.emkt.com.cn/survey/submit_kotter.shtml>
The value attributes of the two INPUT elements above *must* be enclosed in
quotes. Even if browsers like IE parse them correctly, there *will* be
browsers that won't and your page will be not work as you intended with
them.
<INPUT type="hidden" name="recipient">
<INPUT type=submit value=提交 name=Submit>
<INPUT type=submit value=重填 name=Submit2>
The two value attributes above appear to contain non-Latin characters.
These too must be quoted.
</P>
</FORM>


[snipped some end tags]

Hope that helps,
Mike
Jul 20 '05 #6

P: n/a
On 24 Feb 2004 09:21:09 -0800, Robert <rc*******@my-deja.com> wrote:
In article <op**************@news-text.blueyonder.co.uk>,
Michael Winter <M.******@blueyonder.co.invalid> wrote:
To answer your question, use the following:

var mailForm = document.forms[ 'send' ];
mailForm.recipient.value =
mailForm.art.options[ mailForm.art.selectedIndex ].value;


In addition, you need to invoke the above two lines. Add:

<form name="send" method="post" action="send.cgi"
onSubmit="adjustForm()">

in the <head> section place

<SCRIPT type="text/javascript">
function adjustForm {


You mean,

function adjustForm() {

[snip]

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.