nine72 Posted January 28, 2007 Share Posted January 28, 2007 And if so how....ok, so after building several hundred pages of a new web app for the company I work for our biggest client has give us one final request and i just cant do it.What I need to have happen on a web form is this:User enters a 4 digit code into the text field and to the right I need to have it print the definition of what that nubmer is. [u]| Text Box |[/u] print definition of text input.exp. MCC Code: [u]| 5942 |[/u] Book StoresOh, and I can not make a direct query to our db so if that is a way, would have to do it aginst a .txt file.there are a little more than 1100 codes that I have to make this work with so a dropdown is out thanks in advancenine72 Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/ Share on other sites More sharing options...
Tandem Posted January 28, 2007 Share Posted January 28, 2007 Do you mean you want it to happen instantly? If so look into AJAX. Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171453 Share on other sites More sharing options...
Davka Posted January 28, 2007 Share Posted January 28, 2007 [color=beige]there are a little more than 1100 codes that I have to make this work with[/color]Surely there is some sort of rationale behind this code, however - such as, 5507 through 5721 (or whatever) are codes for the Book Stores, etc? Or is it completely random?In other words, it seems to me that what's important is not the number of codes, but the number of definitions (or categories) that these codes correspond to. If there's a reasonable number of categories and if the codes have a logical correlation to each category, it should be fairly simple to write a script that will do what you need.If there's no correlation between the categories and the codes, someone in your programming department needs a dope slap. Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171458 Share on other sites More sharing options...
nine72 Posted January 28, 2007 Author Share Posted January 28, 2007 yeah needs to happen instantly or when they loose focus on that field. My forms are in AJAX but I can't find it there ither.The codes are Merchant Class Codes for the Credit Card Industry they define risk, discounts, charge fees, reserve % etc. The code is what gets passed to my xml generator. The def is for the data monkeys that enter this stuff so they have an "at a glance" notice that they have the right MCC.There are no catagories for these codes, they are a long list of code numbers and def provided by VISA/MasterCard (they use the same codes to set rates). and since a business that sells widgets might be MCC 1000 and a business that sales boxes might be 8000 but a shop that sales widges and boxes might be a 4550. and then again depending on the person that sold the merchant the processing service might say that they are a 0785 for general sundries. its nutty. Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171471 Share on other sites More sharing options...
HuggieBear Posted January 28, 2007 Share Posted January 28, 2007 Nine72,I'd use a bit of Ajax as already suggested, along with file();What's the format of the file, is it comma separated or something?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171475 Share on other sites More sharing options...
matto Posted January 28, 2007 Share Posted January 28, 2007 Could you something like this ? (autocomplete dropdown list)[url=http://www.mattkruse.com/javascript/autocomplete/]http://www.mattkruse.com/javascript/autocomplete/[/url] :) Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171478 Share on other sites More sharing options...
nine72 Posted January 28, 2007 Author Share Posted January 28, 2007 [quote author=matto link=topic=124464.msg515739#msg515739 date=1170027559]Could you something like this ? (autocomplete dropdown list)[url=http://www.mattkruse.com/javascript/autocomplete/]http://www.mattkruse.com/javascript/autocomplete/[/url] :)[/quote]thanks for the link is a good thought but again 1100 plus codes that is a heck of a dropdown. Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171480 Share on other sites More sharing options...
matto Posted January 28, 2007 Share Posted January 28, 2007 I have used this with over 2000 records and it works fine..... Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171483 Share on other sites More sharing options...
JasonLewis Posted January 28, 2007 Share Posted January 28, 2007 are the codes and everything already written out in a file, like: 0001:Book Store,0002:Train Station etc etc. :)then just get the contents of the file, use the explode function on it to split them all into just 0001:Book StoreThen in a for or foreach loop explode them again then create the drop down list. Then use ajax for the rest. Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171485 Share on other sites More sharing options...
HuggieBear Posted January 28, 2007 Share Posted January 28, 2007 [quote author=ProjectFear link=topic=124464.msg515746#msg515746 date=1170028081]are the codes and everything already written out in a file, like: 0001:Book Store,0002:Train Station etc etc. :)then just get the contents of the file, use the explode function on it to split them all into just 0001:Book StoreThen in a for or foreach loop explode them again then create the drop down list. Then use ajax for the rest.[/quote]I was just going to write a bit of example code that did just that...[code]<?php// Get the code passed from the form field$mmc = $_GET['mmc'];// Path to your code file$filepath = 'mmc_codes.txt';// Create an array of the file contents$codes = file($filepath);// Loop through the resultsforeach ($codes as $code){ list($c, $d) = explode(' ', $code); // Split the line on a space ($c is code, $d is description) if ($code == $mmc){ echo $d; }}?>[/code]You can add additional checks into the php, and hey presto.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171486 Share on other sites More sharing options...
nine72 Posted January 28, 2007 Author Share Posted January 28, 2007 [quote author=HuggieBear link=topic=124464.msg515747#msg515747 date=1170028204][quote author=ProjectFear link=topic=124464.msg515746#msg515746 date=1170028081]are the codes and everything already written out in a file, like: 0001:Book Store,0002:Train Station etc etc. :)then just get the contents of the file, use the explode function on it to split them all into just 0001:Book StoreThen in a for or foreach loop explode them again then create the drop down list. Then use ajax for the rest.[/quote]I was just going to write a bit of example code that did just that...You can add additional checks into the php, and hey presto.RegardsHuggie[/quote]Well would you look at that...LOL I think part of my problem was that I was over thinking it. This works beautifully!Thank you for all the assist! Quote Link to comment https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/#findComment-171489 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.