johnhenderson444
|
| Posted: 07/04/2005, 7:03 AM |
|

Hi all,
Just like to say thanks to wkempees for his assistance and examples.
I downloaded and viewed the zip file that you supplied. I managed to get the list box populated and the variable appears in the address bar. I was unable to import it into codecharge and view the actual code. Sorry. I am really stuck with the code side of things.
I want to use an IF/ELSE statement to basically say
if the user selects list item 1 and enters a value in field 2 and selects submit then it should go to page 1.php and perform the query
and if the user selects list item 2 and enters a value in field 2 and selects submit then it should go to page 2.php and perform the query etc.
I know that this code should be in the default page, but am not sure how I should be writing it. Once again thanks.
regards,
John Henderson
|
|
|
 |
johnhenderson444
|
| Posted: 07/04/2005, 7:19 AM |
|
here is an example of what i mean
//Custom Code @72-2A29BDB7
// -------------------------
if
listbox1=1 and keyword<>"" then "page1.php"
else if listbox1=2 and keyword<>"" then "page2.php"
else if listbox1=3 and keyword<>"" then "page3.php"
else if listbox1=4 and keyword<>"" then "page4.php"
end
// -------------------------
//End Custom Code
cheers
john
|
|
|
 |
Martin K.
|
| Posted: 07/05/2005, 1:04 AM |
|
Hello.
You can select a new ReturnPage from the Searchgrid, get the GetValues from the Searchresult in BeforeShow from the new Return Page:
########################################
$listbox = CCGetFromGet("listbox1", 0);
$keyword = CCGetFromGet("keyword", "");
$uri = CCGetQueryString("QueryString", Array("ccsPage"));
// And make a header to the right Page
if($listbox == 1 and $keyword <>"")
header("Location: page1.php?".$uri);
elseif($listbox == 2 and $keyword <>"")
header("Location: page2.php?".$uri);
elseif($listbox == 3 and $keyword <>"")
header("Location: page3.php?".$uri);
elseif($listbox == 4 and $keyword <>"")
header("Location: page4.php?".$uri);
######################################
greets martin
|
|
|
 |
johnhenderson444
|
| Posted: 07/05/2005, 6:59 AM |
|
Hi Martin,
Thanks for your feed back. I am starting to get a hang of things a little bit. I have used your code and and inserted it into the Before Show event. I guess this is under the server side of the events. here is the code...
$listbox = CCGetFromGet("listbox1", 0);
$keyword = CCGetFromGet("s_keyword", "");
$uri = CCGetQueryString("QueryString", Array("ccsPage"));
Finally I put the second bit of code under the submit event, so that the correct page appears when the user submits the page. Here is the code...
{if($listbox == 1 and $keyword <>"")
header("Location: clublist.php?".$uri);
elseif($listbox == 2 and $keyword <>"")
header("Location: drangelist.php?".$uri);
elseif($listbox == 3 and $keyword <>"")
header("Location: hotelslist.php?".$uri);
elseif($listbox == 4 and $keyword <>"")
header("Location: villalist.php?".$uri);}
I have added the braces as codecharge said they were missing?
I have deleted the return page property so that it takes notice of the new code. But it is ignoring the code and staying on the same page when submit is selected. I am not sure what you meant by the following...
You can select a new ReturnPage from the Searchgrid, get the GetValues from the Searchresult in BeforeShow from the new Return Page:
so it is possible that is why it is not working. Lastly you said, make a header to the right Page not sure what you mean by that either. Sorry for my ignorance, i am still a beginner at this... May be looking at the actual page will help you understand what I am after.
http://www.4golfers.co.uk/default.php
regards
john
|
|
|
 |
wkempees
Posts: 1679
|
| Posted: 07/05/2005, 8:37 AM |
|
So you thought I did not notice you went elsewhere 
Assume the Select (Golf Course, etc) field in Default.php is called ListBox1.
Assume the search field is s_text_data.
Your grids are called Grid1, Grid2, and so on.
1: You don't want the user to search with an empty search value.
You are handeling this in code, just put the fields required property Yes.
2: You need to handle the jump to Grid1, Grid2 depending on the value chosen from ListBox1.
You could do this the hard way (and probably the best) but open the properties of Default, your Searchform go to Event and find the Before Unload Event, add Custom Code:
global $ListBox1;
global $Redirect;
if ($ListBox1 == 1)
$Redirect = "Grid1.php";
if ($ListBox1 == 2)
$Redirect = "Grid2.php";
if ($ListBox1 == 3)
$Redirect = "Grid3.php";
if ($ListBox1 == 4)
$Redirect = "Grid4.php";
This should do the trick.
It can be made nicer, cleaner, better but this works.
In the Helpfile (I) search(ed) for Redirect
(80/20 rules! Create 80% functionality in 20% of your time and you'll have plenty left.)
My other solution was to add all 4 grids to the Default page, in BeforeShow $grid1->Visible=false; for all 4 and then depending on the ListBox1 value change the appropriate Grid to true.
I have seen your site and that would have been a little bit more difficult but you would always have had the Search after a search.
All in 1 Page .
Wkempees
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
|