473,382 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Passing paremeter values through url using javascript

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
2 2871
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Raju V.K | last post by:
can I use javascript and PHP in the following manner to create a pop-up window: <--- in <head> </head> <script language=javascript> function popup(folder1, file1) {...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
1
by: franklinbruce | last post by:
Hi all, I have a ASP script which will get 2 query string value. i put val1 Value in a session and pass val2 value to javascript for parent page reload with the specified value. Problem i face is...
16
by: Simon | last post by:
Hi all, I think I've seen someone passing an emumeration in code before. Can anyone tell me if thats possible and why i would want to. Many thanks Kindest Regards
1
by: kai | last post by:
Hi, All I try to use a Webservice CustomerOrderHistory to get customer order by passing a "CustomerID". The Webservice works but the following code Dim ds1 As DataSet Dim CustomerID As...
1
by: | last post by:
Hi, 1st, I did a search and could not find any info on this, the Google results were good, but I'm still have issues...So any help will be great. I have a frame page, which contains 3 frames...
1
by: Adeel Ahmad | last post by:
Hi, The subject sounds confusing but here is what i want to do. I have a button on my page which says...
5
by: sfeher | last post by:
Hi All, I need to call a function(loaded with appendChild) for which I have the name as a string. .... var fnName = 'fn1'; var call = fnName + '('+ param +' )'; eval(call);
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.