-2

I have a website with a contact form.

The form has a field called POS Company Name". I need to populate this field with items that I need to pull from a .json file.

[
    {
        "name": "POSitouch",
        "supportedVersions": [
            "5.36+",
            "6.36+",
            "QuickMenu 2.6.7.12+"
        ]
    },
    {
        "name": "Aloha",
        "supportedVersions": [
            "5.1+"
        ]
    },
    {
        "name": "Posera Maitre'D",        
        "supportedVersions": [
            "7.0"
        ]
    },
    {
        "name": "Veloce",
        "supportedVersions": [
            "6.x",
            "7.x",
            "8.x",
            "9.x"
        ]
    },
    {
        "name": "Azbar AZPos",
        "supportedVersions": [
            "6.x",
            "7.x",
            "8.x"
        ]
    },
    {
        "name": "Dinerware",    
        "supportedVersions": [
            "3.x"
        ]
    },
    {
        "name": "Micros 3700",        
        "supportedVersions": [
            "RES4",
            "RES5"
        ]
    },
    {
        "name": "Micros Simphony",        
        "supportedVersions": [
            "1.6+"
        ]
    },
    {
        "name": "Micros First Edition",        
        "supportedVersions": [
            "1.6+"
        ]
    },
    {
        "name": "EPOS Now",        
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Maxirest",        
        "supportedVersions": [
            "4.9+"
        ]
    },
    {
        "name": "Silverware",        
        "supportedVersions": [
            "Avrio",
            "Legacy"
        ]
    },
    {
        "name": "OKPOS",        
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Tiller",        
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Tango",
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Zonal",       
        "supportedVersions": [
            "Aztec 3.6+"
        ]       
    },
    {
        "name": "Lavu",
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Bepoz/Vectron",       
        "supportedVersions": [
            "4.3+"
        ]       
    },
    {
        "name": "EasyPos",
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "IdealPos",       
        "supportedVersions": [
            "7.x+"
        ]
    },
    {
        "name": "H&L",
        "supportedVersions": [
            "8+"
        ]
    }
]

When a user clicks this field, it needs to show the list of items that are displayed in the .json file. The website can pull this data and store it locally in file or db, or call it on every request.

Ram Chandra Neupane
  • 1,826
  • 3
  • 19
  • 36
  • Your question is not being well received as you're not showing an attempt to solve the problem, you're just describing a feature request... That said, check [here](https://stackoverflow.com/a/43773195/1287812) and [here](https://stackoverflow.com/a/13638937/1287812) for some solutions. – brasofilo Aug 23 '18 at 13:08

1 Answers1

-1

You can user a function with for loop to insert in wordpress html.

window.onload = function load (){
console.log ('readyu');

var json = [
    {
        "name": "POSitouch",
        "supportedVersions": [
            "5.36+",
            "6.36+",
            "QuickMenu 2.6.7.12+"
        ]
    },
    {
        "name": "Aloha",
        "supportedVersions": [
            "5.1+"
        ]
    },
    {
        "name": "Posera Maitre'D",        
        "supportedVersions": [
            "7.0"
        ]
    },
    {
        "name": "Veloce",
        "supportedVersions": [
            "6.x",
            "7.x",
            "8.x",
            "9.x"
        ]
    },
    {
        "name": "Azbar AZPos",
        "supportedVersions": [
            "6.x",
            "7.x",
            "8.x"
        ]
    },
    {
        "name": "Dinerware",    
        "supportedVersions": [
            "3.x"
        ]
    },
    {
        "name": "Micros 3700",        
        "supportedVersions": [
            "RES4",
            "RES5"
        ]
    },
    {
        "name": "Micros Simphony",        
        "supportedVersions": [
            "1.6+"
        ]
    },
    {
        "name": "Micros First Edition",        
        "supportedVersions": [
            "1.6+"
        ]
    },
    {
        "name": "EPOS Now",        
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Maxirest",        
        "supportedVersions": [
            "4.9+"
        ]
    },
    {
        "name": "Silverware",        
        "supportedVersions": [
            "Avrio",
            "Legacy"
        ]
    },
    {
        "name": "OKPOS",        
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Tiller",        
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Tango",
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Zonal",       
        "supportedVersions": [
            "Aztec 3.6+"
        ]       
    },
    {
        "name": "Lavu",
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "Bepoz/Vectron",       
        "supportedVersions": [
            "4.3+"
        ]       
    },
    {
        "name": "EasyPos",
        "supportedVersions": [
            "All Versions"
        ]
    },
    {
        "name": "IdealPos",       
        "supportedVersions": [
            "7.x+"
        ]
    },
    {
        "name": "H&L",
        "supportedVersions": [
            "8+"
        ]
    }
];

function read (){
  for (var i=0; i<json.length; i++){
    // console.log('name: ', json[i].name);  //to write it in the console
    // console.log('version: ', json[i].supportedVersions[0]); //to write it in the console
    document.write(' name: ', json[i].name, "<BR>"); //to write it in html
    document.write(' version: ', json[i].supportedVersions[0], "<BR><BR>"); //to write it in html
  }
}

read();
}
Skatt
  • 372
  • 3
  • 10