I have a multiple select list and I am trying to post to a page where
I have no option to use the request.form or vbscript to iterate
through the control. The page is a sql server reporting services
report. My question is, how can I populate a hidden textbox with
multiple selected values of a select list
1) without using two forms, one posting to populate the textbox with
the list values, and
2) one to post to the report.
right now I am close using javascript:
function onClick(object) {
var allvals='';
for (var Current=0;Current <
object.MyList.options.length;Current++)
{
var text = object.MyTextBox ;
var Mysite = "<%=strWebSite%>"
if (object.MyList.options[Current].selected) {
text.value = object.MyList.options[Current].text ;
allvals=allvals + text.value + ',' ;
}
else {
text.value = '';
}
} location.href= Mysite + '&MyList=' + allvals;
}
</SCRIPT>
The only problem with this method is it returns a value like this:
value1,value2,value3,
I need:
'value1','value2','value3'
This will ultimately be used in a SQL "where in (values)" statement,
which requires strings to have ' qualifiers. I can't figure out how
too add the apostrophes and drop the last comma in javascript. I am
no javascript pro and have scoured the ng looking for examples.
any help is appreciated