Problem with spaces (in a parameter) using onchange event (combo)


                In this JavaScript code I uses two parameters. The first one is a variable. The second one is the option selected in the
                combo box.
                M combo  onchange event
                <select name='ddmCidade'size=1 onchange='javascript:nextPage();'>"
                My JavaScript code is:

                <script language="JavaScript">
                <!--
                function nextPage(cidade)
                {
                var strTemp=document.hiddenform.mystring.value
                strTemp1=document.hiddenform.ddmCidade.options[document.hiddenform.ddmCidade.selectedIndex].value;
                tempUrl = "segunda_pagina.asp?Estado=" + strTemp + "&Cidade=" + strTemp1
                location.href = tempUrl
                }
                //-->
                </script>

                I have a problem with my strTemp1 value that receives the combo option selected.
                Sometimes  strTemp1 receives  a value that has spaces !
                So the line " location.href = tempUrl" gives me a HTTP Error 400 = Bad sintax error.
                I was told before to use this code:
                var1 = replace(var1," ","%20") , but It only works inside an .asp code not in a JavaScript code ! How can I solve this
                problem ?

                                <script language="JavaScript">
                                <!--
                                function nextPage(cidade)
                                {
                                var strTemp=document.hiddenform.mystring.value
                                strTemp1=document.hiddenform.ddmCidade.options[document.hiddenform.ddmCidade.selectedIndex].value;


                                tempUrl = "segunda_pagina.asp?Estado=" + strTemp + "&Cidade=" + strTemp1
                                location.href = tempUrl
                                }
                                //-->
                                </script>
gferroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brigmarCommented:
qferro,

use :

 strTemp1.split(" ").join("%20");

Brian
0
pappalaCommented:
u can use

strtemp1.replace(" ","%20")

and let me know.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pappalaCommented:
it is working for me in IE4.0. i will let u know if it is successful with Netscape also.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

pappalaCommented:
it is working for me in IE4.0. i will let u know if it is successful with Netscape also.
0
pappalaCommented:
in netscape it is replacing only one space for the replace function. so u use
a do ... while loop.
0
gferroAuthor Commented:
Thanks a lot it worked !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.