...

View Full Version : Need assistance manipulating text fields



trsands
01-03-2004, 01:49 AM
I know this should be simple but I cant get it to work.
1) I create a page in DreamWeaver doc type CFM (cold fusion)

2) I have 3 text input files, a selection box and 2 button s

3) What I want is when I click on the first button for:
a) the 3 text fields to be concatenated into a single string
b) the resulting string to be added to the selection list
producing a scrollable list of all entries
c) I also want the strings to be added to array
d) Clear input fields for new input

4) When I press the second button (submit)
I want the array to be passed to the action page for processing

Im new to both CF and JS but I have been programming for years. Need help must present this on Monday Jan 5th
Unfortunately my script is on PC at work And I cant include it here

COBOLdinosaur
01-03-2004, 08:57 PM
I don't get in volved with development tools. I can do better job than product that thinks it know how to generate code. So here is what it has to look like to the browser in HTML and JavaScript. How you get it to generate out of the toys i don't know.

Like this:

<html>
<head>
<title> Send Concatenated array</title>
<script type="text/javascript">
<!--
var strs = new Array();
function saveIn()
{
frm=document.forms['main'];
strs[strs.length]=frm.text1.value+frm.text2.value+frm.text3.value;
frm.thesel[frm.thesel.length] = new Option(strs[strs.length-1],strs[strs.length-1]);
document.forms['theform'].thedata.value=strs.join();
}
//-->
</script>
</head>
<body>
<form name="main">
Text 1: <input type="text" name="text1">
Text 2: <input type="text" name="text2">
Text 3: <input type="text" name="text3">
<br />
<select name="thesel" size="4"></select>
<input type="reset" value="Save to List"
onClick="saveIn()">
</form>
<br />
<!-- form name="theform" action="yourscript.php" -->
<form name="theform" action="JavaScript:alert(document.forms['theform'].thedata.value)">
<input name="thedata" type="hidden">
<input type="submit">
</form>
</body>
</html>

I sized the select at 4. If you want a different size just change that value. If you want a dropdown instead, just remove the size property. The data going across is a comma serated list. if you want to use something different than a comma, just put it as the aregument of the join. Tested with IE6 and Mozilla 1.4



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum