Parsing Checkbox Url

SteveO 30 Sep, 2007
First of all, thanks for a great component!

My particular form uses the GET attribute to submit to a URL that will take the information selected in the form, and filter the resulting page information by that criteria. My particular usage is for real estate.

So the problem I have is that the particular method that I'd like the user to select their options won't work with the way the URL is being sent over.

I currently have the criteria via a series of checkboxes, so when the submit button is pressed and the info passed, the URL propagates as follows:

www.myurl.com/index.html?singlefamily=on&multifamily=on


Is there a way I can have this come out like this instead?

www.myurl.com/index.html?type=singlefamily,multifamily


So that if they don't select that particular type, then it doesn't come up in the URL? I'd also be stumped as to how the "type" variable will be referenced, since I'm using checkboxes.

The current code I'm using is:

<fieldset class="propsearch_type">
<legend class="propsearch">Property Type</legend>
<table width="100%">
<tr>
<td><label for="singlefamily" class="propsearch_labels">Single Family</label>
<input type="checkbox" id="singlefamily" name="singlefamily" tabindex="1" />
</td>
<td>
<label for="townhomecondo" class="propsearch_labels">Townhome/Condo</label>
<input type="checkbox" id="townhomecondo" name="townhomecondo" tabindex="2" />
</td>
<td>
<label for="rentals" class="propsearch_labels">Rentals</label>
<input type="checkbox" id="rentals" name="rentals" tabindex="3" />
</td>
</tr>
</table>
</fieldset>


Thanks for any help in advance!<br><br>Post edited by: SteveO, at: 2007/09/29 20:24
Max_admin 30 Sep, 2007
Hi Steve,

It's not good at all to pass long values with the GET method as it has maximum character limit, why can't you do this with the POST method, thats really the best when you want to pass an array of values as you wish🙂

but anyway, if you want to solve your problem above, you can use a hidden field with name type then use javascript to edit this field value upon every checkbox click!!

Let me know your thought!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
SteveO 30 Sep, 2007
Hi Max!

Thanks for the quick reply. I tried using the POST method, but the variables weren't passed like I need it to be. I'm passing the search results to a wrapper in Joomla, and in doing so, POST doesn't seem to work (perhaps I'm doing something wrong?).

So it's possible to fix this, horraay! You'll have to forgive me, but can you give me a framework for the javascript I should use with the form? I'm not familiar with java at all (I know, I should be!)
Max_admin 30 Sep, 2007
Hi Steve,

So the script expects a string of values with commas in between like this : singlefamily,multifamily ? no other format ? doesn't it accept any posted values ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
SteveO 30 Sep, 2007
It accepts other; I just excerpted the entire form to save a long explanation. All the other values work out great, as they come out as:

www.myurl.com/index.html?min_bedrooms=2&min_price=100000


But that's because those are via a select attribute. I've tried:

www.myurl.com/index.html?subdivision=subdivision1,subdivision2&min_price=100000


And that worked okay, so was assuming that if I could get this to work via a form the way so that the user can add/change what they want on the front end instead of me manually specifying the URL.

I hope that's not too confusing.😟

By the way, if you're up to it, I'll gladly email you the URL I'm working. I just don't want it public just yet.

Post edited by: SteveO, at: 2007/09/29 21:15<br><br>Post edited by: SteveO, at: 2007/09/29 21:16
SteveO 30 Sep, 2007
I actually got it to work with a the supplied script from the company I'm using to show the property listings:

<td>
<select name="tmp_property_type" style="width: 120px;" onchange="updatePropertyType(this);">
<option value="">- Property Type -</option>
<option value="condo">Condo</option>
<option value="lots_acreage">Lots/Acreage</option>
<option value="multi_family">Multi-Family</option>
<option value="residential_lease">Residential Lease</option>
<option value="single_family">Single Family</option>
</select>
<input name="condo" value="" type="hidden">
<input name="lots_acreage" value="" type="hidden">
<input name="multi_family" value="" type="hidden">
<input name="residential_lease" value="" type="hidden">
<input name="single_family" value="" type="hidden">
</td>

function updatePropertyType(p_obj) {
var frm = p_obj.form;
for (var i = 0; i < p_obj.options.length; i++ ) {
var field = p_obj.options[i].value;
if (field != ""«») frm[field].value = (i == p_obj.selectedIndex) ? "Y" : "";
}
}


Now the question is; how the heck do I change the HTML to allow it to work with checkboxes and not a drop down list?

(Driving myself nuts today, haha)
Max_admin 30 Sep, 2007
Hi steve,

Glad we have partial solution works now🙂 , sorry Iam just missing something, why do we need it as checkboxes ?🙂
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
SteveO 30 Sep, 2007
Purely cosmetic. I want to see if a checkbox approach is more friendly than a list.

Do you think it's possible, or worth trying?
Max_admin 30 Sep, 2007
It is, but the issue is that multi checkboxes will send an array but this dropdown will send 1 value only, also the receiver script may not be prepared to get an array value, did you try to send a list with commas to it ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.