Hi All,
I am trying to add a script that produces a link with values and I am having trouble getting a multi select field to produce the correct URL output.
For example:
Code javascript:function evalURL() { var tempStr = ""; tempStr="http://link.somedomain.com/somedirectory/begin&"+document.form1.value+"&"; tempStr += "MyValuetype="+document.form1.MyValuetype.value+"&"; tempStr += "city="+document.form1.city.value+"&"; document.location=tempStr; }
The HTML Looks Like This:
That all works ok, however the string above for the city works if my html only selects one city. But I need to Select Multiple cities and have the output reflect thatHTML Code:Select Type: <select name="MyValuetype"> <option value="Type1">Type 1</option> <option value="Type2">Type 2</option> <option value="Type3">Type 3</option> <option value="Type4">Type 4</option> </select> (REQUIRED)</font><p> <font face="Arial"> <br />
String:
Code javascript:tempStr += "city="+document.form1.city.value+"&";
HTML:
If I select Type 2 for the first selection and Multiple Cities, City 1, 3, 5 & 7 the out put link when I press the submit button should look like this:HTML Code:<font face="Arial"> Select City: <select name="city" multiple="multiple" size="5"> <option selected="selected" value="">All</option> <option value="City1,">City 1</option> <option value="City2,">City 2</option> <option value="City3,">City 3</option> <option value="City4,">City 4</option> <option value="City5,">City 5</option> <option value="City6,">City 6</option> <option value="City7,">City 7</option> </select>
However I get This:Code:http://link.somedomain.com/somedirectory/begin&MyValuetype=Type2&city=City1,City3,City5,City7
How do I adjust the String to Allow for multiple selections separated by a comma?Code:http://link.somedomain.com/somedirectory/begin&MyValuetype=Type2&city=City1
And another question I had was How do I omit the field all together if it is not selected. If the Form field is any or all or not required by the user it should not be added to the string the output contains the data request but the value is either blank or whatever I tell it, but it messes up the output sting.
If I did a poor job explaining this, please let me know I will try again.
Thank You ALL in advance!!!!!





Bookmarks