jmansa — 2010-04-25T06:41:15-04:00 — #1
I'm trying to send data to 2 different functions using the same selectbox. 1 function only needs a "ID" as value like this:
<select name="ccountry" onchange="getState(this.value)">
The other one needs an url like this:
<select id="ajaxmenu" onChange="ajaxcombo('ajaxmenu', 'contentarea')">
Is there any way to do so?
raffles — 2010-04-25T07:36:47-04:00 — #2
Yes, you would have to do some simple string manipulation within your ajaxcombo function. The way you have it set up at the moment, your ajaxcombo is just receiving two static strings. You also need it to receive
this.value like your first function (so a third argument). Then extract the code number from the string, using a regular expression or one of the string functions.
jmansa — 2010-04-25T10:03:40-04:00 — #3
Well, trying to leave the ajaxcombo as is, but trying to extract the "code=1" part from the string like this:
var URL = "ajax.php?page=country&code=1";
var d = URL.lastIndexOf("code");
var newURL = URL.substring(d);
But... Gives me to problems:
The alert comes out like this: "code=1", and all I want is the "1", and what if I have a urlstring like this:
var URL = "ajax.php?page=country&code=1&id=15";
and I only want the "code" value...