Jump to content

Recommended Posts

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 Stores

Oh, 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 advance
nine72
Link to comment
https://forums.phpfreaks.com/topic/36111-solved-is-this-even-possible/
Share on other sites

[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.
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 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.
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 Store
Then in a for or foreach loop explode them again then create the drop down list. Then use ajax for the rest.
[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 Store
Then 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 results
foreach ($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.

Regards
Huggie
[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 Store
Then 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.

Regards
Huggie
[/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!
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.