simple question: translate select values into a hidden text box

C

calfliu

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!
 
M

Michael Winter

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
 
R

Robert

Michael Winter said:
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
 
C

calfliu

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="(e-mail address removed)"> OR
<input type=hidden name="recipient"
value="(e-mail address removed),[email protected]">

so what shall I do. pls help
 
R

Robert

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
 
M

Michael Winter

[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]

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>

<a href="http://www.emkt.com.cn/intro/emkt_shanghai.html"
<a href="http://www.emkt.com.cn/intro/emkt_wuhan.html"
</div>
</p>

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

</p>
<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
 
M

Michael Winter

Michael Winter said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top