This topic is locked
[SOLVED]

 Looking for suggestion on best approach

2/21/2012 8:56:29 AM
PHPRunner General questions
W
wildwally author

I've searched high and low withnin the formums and have found stuff close in nature but they still lack the level of complexity I believe I need to complete this task. And I want to make sure i'm doing it right so as not to end up like the last project that ended up corrupt and throwing nothing but errors that I can't seem to figure out how to fix.
So I want to reduce the number of variations of entries by my users by having them use a zip code entry and lookup. My thought is the user would click a button on my add page that would popup a form with a field for them to enter a zipcode and a button to click once entered.
when the user clicks the button a query needs to be run to use the zipcode entered and return all cities corrisponding to the zipcode. In some cases it would only be one and others it could be many. If only one city is found enter that into the city field on the add page. If more than one city returned than display the results for the user to clcik on or select the one they need and then enter that into the city field on the add page. After the city and zipcode have been provided I would need to run another query to populate the state or from the previous queries populate the state field on the add page. The city and state fields are contained in the same table dbo._zipdata.
I don't have anything to show as of yet, looking for suggestions and pointeres as to how this could be done the most effienct method and not going to corrupt my rework.
Thanks in advance.

W
wildwally author 2/21/2012

Is it possible to populate a fields drop down list after the page has been loaded?
I was thinking it might be possible to have the user enter the zip code in the zip field and click a button which would then run the client before:


//Client Before:
params["Uzip"] = $("Zip").val();
//Server:
global $conn;

$str = "SELECT * FROM _ZipData WHERE PostalCode=" . $params["Uzip"];

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$result["Uzip"] = $data["CityName"];
//Client After:
$("City").val() = result["Uzip"];


Of course this is not working at the moment but maybe someone can get an idea of what i'm trying to do.
The city field would then have the ruery results for the user to select.

Sergey Kornilov admin 2/21/2012

How's about using dependent dropdown boxes? The first dropdown box can be setup as 'Edit box with AJAX popup'.

W
wildwally author 2/21/2012



How's about using dependent dropdown boxes? The first dropdown box can be setup as 'Edit box with AJAX popup'.


I've tried this suggestion; however, due to the quantity of records in the table it renders the site useless.

Sergey Kornilov admin 2/21/2012

Why? Did you see the AJAX note?

W
wildwally author 2/21/2012

talking over 900k records (apparently canada likes postal codes). when i click on the list page it never completes the load to allow me to get to the add page.

Sergey Kornilov admin 2/21/2012

I don't think we are on the same page. Dropdown implemented as 'Edit box with AJAX popup' never loads the whole list of values from the database.

W
wildwally author 2/21/2012



I don't think we are on the same page. Dropdown implemented as 'Edit box with AJAX popup' never loads the whole list of values from the database.


I can get the Ajax to work fine on the zip code (postal code) itself just fine. Once I add the dependency all heck starts. If i try to test it in PHPRunner it locks up the program - (Not Responding) at top. And if I build it the list page never loads.
Edit I let test it within PHPRunner continue and it finally loaded. Apparently the PHPRunner test doesn't do Ajax, which is why it took forever to load. But testing through the browser still results in either no load or its extremely long load time and i'm not waiting long enough. So I don't think the dependencies is going to be the best action unless there is something else i'm missing.

Sergey Kornilov admin 2/21/2012

I guess you are missing something. Probably you can test it first on smaller dataset to make sure setup is correct.
PS. Test in PHPRunner doesn't do AJAX. You cannot perform AJAX requests without a browser. It simply shows you all data in the table.

W
wildwally author 2/21/2012



I guess you are missing something. Probably you can test it first on smaller dataset to make sure setup is correct.
PS. Test in PHPRunner doesn't do AJAX. You cannot perform AJAX requests without a browser. It simply shows you all data in the table.


Your suggestion works with smaller data set as I tried on another instance. The only way i could get the larger data set to work was by making the dependant field also Ajax, which is not what I was looking for. Had all my results only have one possible return I could do this with the resulting output. However, I want the user to have a visible narrowed selection in a drop down field when multiple results/options are presented.
Is there anyway to populate the contents of a dropdown box by posting the results of a query to the field?
I was able to make some more success with my first attempts in earlier post and using javascript button and returning value from query. Is there a way I could post this to a popup and allow user to select result in popup which would post result to field? As long as the data is unique in the list should not much longer than 10 entries.

Sergey Kornilov admin 2/21/2012

Hard to tell what is not working with larger datasets. Probably some additional setup is required or some indexes are missing in the database. Probably you can show us a URL of this app.
It's also possible to have user simply enter ZIP code first and then execute an AJAX requests to get the list of cities and populate a dropdown box. This will require manual coding though and you will need to handle both client side and server side code. At the end it will be doing the same job that dependent dropdowns do so there is a possibility you encounter the same sort of issue.

W
wildwally author 2/21/2012



Hard to tell what is not working with larger datasets. Probably some additional setup is required or some indexes are missing in the database. Probably you can show us a URL of this app.
It's also possible to have user simply enter ZIP code first and then execute an AJAX requests to get the list of cities and populate a dropdown box. This will require manual coding though and you will need to handle both client side and server side code. At the end it will be doing the same job that dependent dropdowns do so there is a possibility you encounter the same sort of issue.


When I run it through firebug there is no error, it's just too much info. It looks like its building the list in the background based on the code when i expand it.
Your second idea was actually the direction i was trying to head. Where the user enters the zipcode and the results pulled back, smaller list to deal with. I've got the client side before getting the user entered value and passing to the server for the query (below), what i need direction on is showing all the results and displaying in a manner for the user to click on.


//Client Before:

var Entzip = Runner.getControl(pageid, 'Zip');

params["zip"] = Entzip.getValue();

alert (params["zip"]);
//Server:

global $conn;

$str = "SELECT * FROM _ZipData WHERE PostalCode=" . $params["zip"];

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$result["Uzip"] = $data["CityName"];
//Client After:

alert(result["Uzip"]);

var Entzip = Runner.getControl(pageid, 'City');

Entzip.setValue(result["Uzip"]);


The above code only display the first result, something is not right there - the test I used should have three results.
And I need guidance on sending this to a popup.
Thanks in advance.

P
procheck 2/21/2012

Postal codes are similar to zip codes. They narrow is down to the street. If you only want the city, the you might try searching on the first 3 digits instead of the whole code. That might reduce your results.
Postal Code Structure

W
wildwally author 2/21/2012

Sergey, when i go straight to the add page it loads instantly. But if I load through the list page it drags out?
This is what firebug shows.
Use of getAttributeNodeNS() is deprecated. Use getAttributeNS() instead.GET localhost:8085/Copy_of_dboQuoteRequests...Parent=0&type=SELECT&mode=2&rndVal=1329862882584

loadfirst.js (line 2)GET localhost:8085/Copy_of_dboQuoteRequests...Parent=0&type=SELECT&mode=2&rndVal=1329862882605

Why would the list page be loading this?

Sergey Kornilov admin 2/22/2012

Not enough info to provide a meaningful answer.

W
wildwally author 2/22/2012

Found another way to accomplish the same result although it requires a little more work on my end I think the outcome will be worth while.
I've run into another issue with the same topic so to speak.
On the Add page I want to look up the zipcode and put that value into the field prior to it being added to the database. Here is my the code I'm having problems with:



global $conn;

$str = "SELECT * FROM _ZipData WHERE CityName='".$values['Ucity']."' AND State_Providence_name='".$values['Ustate']."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$values['Zip'] = $data["PostalCode"];


I don't see anything out of the ordinary that - i've tried the query by itself and it works. but when running it in the site nothing is returned or entered into the Zip column.
Do you see any reason why this would not return the postal code?

Sergey Kornilov admin 2/22/2012

Print $data["PostalCode"] on the page to make sure it's populated properly.

W
wildwally author 2/22/2012



Print $data["PostalCode"] on the page to make sure it's populated properly.


Your saying to add this below the code I provided and try it - assuming it should display the value? Much like an Echo would.
Tried this and got nothing. But I think I see what the problem is when I tried this with the values feeding the query. The above works when you select the right field to look up.