By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,369 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,369 IT Pros & Developers. It's quick & easy.

Passing paremeter values through url using javascript

P: n/a
Hello

I have the following tag

<select name="cat" id="cat"
onchange="popUpWin('cmPhaseReload.php?category='+d ocument.getElementById('cat').options[document.getElementById('cat').selectedIndex].value
,600,600,'yes')" class="tbl_result" size="1">

the cat field is a drop down list

here's my problem

some values for the drop down have values with a space on it.

ABC DEF

when I try to pass the value to the other page I only get the ABC part.

How can I correctly pass the value?

someone told me to use a function called escape

sorta like

escape(document.getElementById('cat').options[document.getElementById('cat').selectedIndex].value)

but that didn't seem to work.

can someone help the newbie out here?

Thanks
Peter
May 15 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Peter said the following on 5/15/2006 9:34 AM:
Hello

I have the following tag

<select name="cat" id="cat"
onchange="popUpWin('cmPhaseReload.php?category='+d ocument.getElementById('cat').options[document.getElementById('cat').selectedIndex].value
,600,600,'yes')" class="tbl_result" size="1">
Try navigating that select with your keyboard....

But, if the onchange is firing off the select, and you are passing the
selects value, you can drop the document.get..... and just reference
this.value:

onchange="popUpWin('cmPhaseReload.php?category='+t his.value+'....)"
the cat field is a drop down list

here's my problem

some values for the drop down have values with a space on it.

ABC DEF


Quote your values
e.g.:
<option value="ABC DEF">
instead of:
<option value=ABC DEF>

The second does what you describe, the first doesn't.

Validating the HTML would have caught that.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 15 '06 #2

P: n/a
Randy Webb wrote:
Peter said the following on 5/15/2006 9:34 AM:
Hello

I have the following tag

<select name="cat" id="cat"
onchange="popUpWin('cmPhaseReload.php?category='+d ocument.getElementById('cat').options[document.getElementById('cat').selectedIndex].value
,600,600,'yes')" class="tbl_result" size="1">


Try navigating that select with your keyboard....

But, if the onchange is firing off the select, and you are passing the
selects value, you can drop the document.get..... and just reference
this.value:

onchange="popUpWin('cmPhaseReload.php?category='+t his.value+'....)"
the cat field is a drop down list

here's my problem

some values for the drop down have values with a space on it.

ABC DEF


Quote your values
e.g.:
<option value="ABC DEF">
instead of:
<option value=ABC DEF>

The second does what you describe, the first doesn't.

Validating the HTML would have caught that.


Randy

You pointed me to the right direction, it was the quotes on the value

Thanks alot
Peter
May 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.