Passing paremeter values through url using javascript

P

Peter

Hello

I have the following tag

<select name="cat" id="cat"
onchange="popUpWin('cmPhaseReload.php?category='+document.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
 
R

Randy Webb

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='+document.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='+this.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.
 
P

Peter

Randy said:
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='+document.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='+this.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top