473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Parsing returned values from a multiple selection list in a form

I have a form that I am using to generate an email with several user
selected fields being part of it. As part of this form, I have a select
box which allows the user to select which email addresses it should be
sent to. The box works great except that the CGI script I'm sending the
values to can only parse a single line for each field in the form. The
issue comes into play when someone selects more than one value in the
select box, the output of the select box seems to separate each value
on a separate line using a line feed (or carriage return, I can't
tell). The format that the CGI script needs is for a single line with
each of these values separated by a comma. I'm confident that a
javascript can do this fairly easily, but unfortunately, I am not very
well versed in javascript. I've found a few code snippets on the web
that I've mangled together, but since I don't really know what I'm
doing, it isn't working out so good. I've included what I have in the
form right now below (note that I've removed all of the other form data
but the select box code to save space). If anybody could point out what
I'm doing wrong, I would be most greatful!
<script language="JavaScript">
<!-- Start
function replaceChars(entry) {
out = "\n"; // replace this
add = ","; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.form.list.value = temp;
--End
</script>

<body>
<form name="form" method="post" action="/cgi-bin/soupermail.cgi"
onsubmit="replaceChars(document.form.list.value);r eturn
document.form.list.value">
<select name="list" size="6" multiple id="select">
<option value="us***@hotmail.com">User 1</option>
<option value="us***@hotmail.com">User 2</option>
<option value="us***@hotmail.com">User 3</option>
<option value="us***@hotmail.com">User 4</option>
<option value="us***@hotmail.com">User 5</option>
<option value="us***@hotmail.com">User 6</option>
</select>
<input name="button_submit" type="submit" id="button_submit"
value="Send Email">
</form>
</body>

Jan 5 '07 #1
1 2368
BUMP
DigitalPrankster wrote:
I have a form that I am using to generate an email with several user
selected fields being part of it. As part of this form, I have a select
box which allows the user to select which email addresses it should be
sent to. The box works great except that the CGI script I'm sending the
values to can only parse a single line for each field in the form. The
issue comes into play when someone selects more than one value in the
select box, the output of the select box seems to separate each value
on a separate line using a line feed (or carriage return, I can't
tell). The format that the CGI script needs is for a single line with
each of these values separated by a comma. I'm confident that a
javascript can do this fairly easily, but unfortunately, I am not very
well versed in javascript. I've found a few code snippets on the web
that I've mangled together, but since I don't really know what I'm
doing, it isn't working out so good. I've included what I have in the
form right now below (note that I've removed all of the other form data
but the select box code to save space). If anybody could point out what
I'm doing wrong, I would be most greatful!
<script language="JavaScript">
<!-- Start
function replaceChars(entry) {
out = "\n"; // replace this
add = ","; // with this
temp = "" + entry; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add +
temp.substring((pos + out.length), temp.length));
}
document.form.list.value = temp;
--End
</script>

<body>
<form name="form" method="post" action="/cgi-bin/soupermail.cgi"
onsubmit="replaceChars(document.form.list.value);r eturn
document.form.list.value">
<select name="list" size="6" multiple id="select">
<option value="us***@hotmail.com">User 1</option>
<option value="us***@hotmail.com">User 2</option>
<option value="us***@hotmail.com">User 3</option>
<option value="us***@hotmail.com">User 4</option>
<option value="us***@hotmail.com">User 5</option>
<option value="us***@hotmail.com">User 6</option>
</select>
<input name="button_submit" type="submit" id="button_submit"
value="Send Email">
</form>
</body>
Jan 8 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: João Proença | last post by:
Ok the problem is this, when i try to receve the values from a form with the selection list below: <select name="jogos" size="5" multiple id="jogos"> <option value="1">Battlefield 1942</option>...
18
by: booner | last post by:
I have a form that when it loads I would like to highlight the values (from a DB) that have been selected in a multiple selection list (<select multiple="true">. function onLoad() {...
2
by: Peter | last post by:
Hello! Please, could anyone tell, is it possible to set multiple items to be selected in list control in the code? For example when the web form is loaded three items of 5 are selected in list...
2
by: bienwell | last post by:
Hi all, I've got a problem with getting the data values from multiple selections in the list box. I could only get the value and the index of the first item from the selection, but not the...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
1
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
1
by: Rick Owen | last post by:
Greetings, I have a form that, when submitted, calls a plsql procedure. The form has a number of fields (text, hidden, select, radio) but the particular field that is giving me problems is a...
1
nine72
by: nine72 | last post by:
Ok, I am at a complete loss on this and have finally come to the XML Parsing Gods (and perhaps a PHP minor deity) for guidance… I will try my best to describe what I have going on… 1) I have 15...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.