I currently have a request form set up that allows users to make multiple requests by clicking a button to add new fields. The request entries are then output as comma-delimited lists, which are processed using Coldfusion. So far, so good.
The problem is that many of the requests will include a comma in one of the form fields, and thus Coldfusion will assume that everything in the field after the comma is in the next list element. So, where the user might request 3 copies of product A with the notes "Volumes 1, 2 and 3" and 5 copies of product B with the notes "Paper stick," it comes through as 3 copies of product A with notes "Volumes 1" and 5 copies of product B with notes "2 and 3".
I tried fixing this with a replacechars function, which would replace all commas with the ` character (not too likely to be used in a note) and then having Coldfusion convert the ` characters back to commas after pulling the element from the list. This worked for the first field, but the subsequent fields, populated by the addto function, couldn't seem to call it. Any suggestions?
Here's my code:
<script>
// Show/Hide functions for non-pointer layer/objects
function shownon(showobj,TheTop) {
document.all[showobj].style.display = "block"
//I added this to show the button too.
//document.all['layer3'].style.display = "block"
}
function hidenon(hideobj) {
document.all[hideobj].style.visibility = "hidden"
}
function replaceChars(entry) {
out = ","; // 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.thisform.notes.value = temp;
}
//Function to add another Record.....Just modify the strHTML string to add more.
function addmore(Theobj) {
var strHTML
strHTML='<BR><INPUT type="text" name="need" size="3" maxlength="3"> <select name="file_type"><option value="" selected>Select Type of File</option><cfoutput query="label_names"><option value="#label_name#">#label_name#</cfoutput></option></select> <INPUT type="text" name="notes" size="40" value=" " onBlur="replaceChars(this.value);">'
document.all[Theobj].insertAdjacentHTML('BeforeEnd',strHTML)
}
</script>
<table>
<TR>
<TD colspan="3">Sub-File Labels Requested:</TD>
</TR>
<TR>
<TD>QTY</TD>
<TD>FILE TYPE</TD>
<TD>LABELING NOTE (NEXT VOLUME NUMBER/DETAIL)</TD>
<td> </td>
</TR>
</table>
<FORM action="_subfile_new.cfm" name="thisform" onSubmit="return validateForm(this)" method="post">
<INPUT type="text" name="need_1" size="3" maxlength="3">
<select name="file_type_1">
<option value="" selected>Select Type of File</option>
<cfoutput query="label_names">
<option value="#label_name#">#label_name#</option>
</cfoutput>
</select>
<INPUT type="text" name="notes_1" size="40" value=" ">
<A href="javascript:shownon('layer2','0');">Add</A>
<div id="layer2">
<INPUT type="text" name="need" size="3">
<select name="file_type">
<option value="" selected>Select Type of File</option>
<cfoutput query="label_names">
<option value="#label_name#">#label_name#</option>
</cfoutput>
</select>
<INPUT type="text" name="notes" size="40" value=" " onBlur="replaceChars(this.value);">
<A href="javascript:addmore('layer2');">Add More</A>
</div>
</form>
The problem is that many of the requests will include a comma in one of the form fields, and thus Coldfusion will assume that everything in the field after the comma is in the next list element. So, where the user might request 3 copies of product A with the notes "Volumes 1, 2 and 3" and 5 copies of product B with the notes "Paper stick," it comes through as 3 copies of product A with notes "Volumes 1" and 5 copies of product B with notes "2 and 3".
I tried fixing this with a replacechars function, which would replace all commas with the ` character (not too likely to be used in a note) and then having Coldfusion convert the ` characters back to commas after pulling the element from the list. This worked for the first field, but the subsequent fields, populated by the addto function, couldn't seem to call it. Any suggestions?
Here's my code:
<script>
// Show/Hide functions for non-pointer layer/objects
function shownon(showobj,TheTop) {
document.all[showobj].style.display = "block"
//I added this to show the button too.
//document.all['layer3'].style.display = "block"
}
function hidenon(hideobj) {
document.all[hideobj].style.visibility = "hidden"
}
function replaceChars(entry) {
out = ","; // 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.thisform.notes.value = temp;
}
//Function to add another Record.....Just modify the strHTML string to add more.
function addmore(Theobj) {
var strHTML
strHTML='<BR><INPUT type="text" name="need" size="3" maxlength="3"> <select name="file_type"><option value="" selected>Select Type of File</option><cfoutput query="label_names"><option value="#label_name#">#label_name#</cfoutput></option></select> <INPUT type="text" name="notes" size="40" value=" " onBlur="replaceChars(this.value);">'
document.all[Theobj].insertAdjacentHTML('BeforeEnd',strHTML)
}
</script>
<table>
<TR>
<TD colspan="3">Sub-File Labels Requested:</TD>
</TR>
<TR>
<TD>QTY</TD>
<TD>FILE TYPE</TD>
<TD>LABELING NOTE (NEXT VOLUME NUMBER/DETAIL)</TD>
<td> </td>
</TR>
</table>
<FORM action="_subfile_new.cfm" name="thisform" onSubmit="return validateForm(this)" method="post">
<INPUT type="text" name="need_1" size="3" maxlength="3">
<select name="file_type_1">
<option value="" selected>Select Type of File</option>
<cfoutput query="label_names">
<option value="#label_name#">#label_name#</option>
</cfoutput>
</select>
<INPUT type="text" name="notes_1" size="40" value=" ">
<A href="javascript:shownon('layer2','0');">Add</A>
<div id="layer2">
<INPUT type="text" name="need" size="3">
<select name="file_type">
<option value="" selected>Select Type of File</option>
<cfoutput query="label_names">
<option value="#label_name#">#label_name#</option>
</cfoutput>
</select>
<INPUT type="text" name="notes" size="40" value=" " onBlur="replaceChars(this.value);">
<A href="javascript:addmore('layer2');">Add More</A>
</div>
</form>