Проблема в отображении Intger при поиске по вводу и добавлении ссылки в коде - PullRequest
0 голосов
/ 29 декабря 2018

Я создаю сайт, который позволяет пользователям искать свойства, а затем они могут перейти на другую страницу, которая показывает им полную спецификацию свойства.Но при поиске свойства с использованием целого числа (год, день, количество спален) целое число не отображается.Я не уверен, почему это происходит.

Кроме того, есть ли способ связать искомое свойство с другой страницей в теге скрипта.

Большое спасибо!

1 Ответ

0 голосов
/ 29 декабря 2018

<!doctype html>
<html>

<head>
    <meta charset="utf-8">    
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>

<body>
        <form>
            <input type="text" id="searchLocation" name="searchLocation">
            <script>
                var data = {
                    "properties": [
                        {
                            "id": "prop1",
                            "type": "House",
                            "bedrooms": 3,
                            "price": 650000,
                            "tenure": "Freehold",
                            "description": "Attractive three bedroom semi-detached family home situated within 0.5 miles of Petts Wood station with fast trains to London and within easy walking distance of local shops, schools, bus routes and National Trust woodland. The property comprises; two receptions, fitted 18'9 x 10'1 kitchen/breakfast room and conservatory. The property also benefits from having a utility room and cloakroom. To the first floor there are three bedrooms and a family bathroom with separate WC. Additional features include double glazing, gas central heating and a well presented interior...",
                            "location": "Petts Wood Road, Petts Wood, Orpington",
                            "picture": "images/prop1pic1small.jpg",
                            "url": "properties/prop1.html",
                            "added": {
                                "month": "March",
                                "day": 12,
                                "year": 2018
                            }
                        },

                        {
                            "id": "prop2",
                            "type": "Flat",
                            "bedrooms": 2,
                            "price": 299995,
                            "tenure": "Freehold",
                            "description": "Presented in excellent decorative order throughout is this two double bedroom, two bathroom, garden flat. <br>The modern fitted kitchen is open plan to the living room which boasts solid wooden floors and includes integrated appliances including a dishwasher & a washing machine. This large open plan benefits from bi folding doors onto a secluded private courtyard garden. Both bedrooms are double sized, and the family bathroom boasts a matching three piece suite a shower attachment over the bath. There is also a separate wet room. There are walnut doors throughout and wiring for Sky TV/aerial points in the living room/kitchen and both bedrooms.<br>This apartment being only five years old, is still under a 10 year building guarantee...",
                            "location": "Crofton Road Orpington BR6",
                            "picture": "images/prop2pic1small.jpg",
                            "url": "properties/prop2.html",
                            "added": {
                                "month": "September",
                                "day": 14,
                                "year": 2018
                            }
                        },
                    ]
                };

                var dataType = [];

                for (var i in data.properties) {
					dataType.push(data.properties[i].type);
					dataType.push(data.properties[i].added.month.toString());
					dataType.push(data.properties[i].added.day.toString());
                    dataType.push(data.properties[i].added.year.toString());

                    console.log(dataType)
                    $("#searchLocation").autocomplete({
                        source: dataType,
						
                    });
                }
            </script>
        </form>
</body>
</html>

Я думаю, вам нужно вставить массив, не назначая его.

...