parent
1480d09187
commit
87d711b04a
@ -1,11 +1,15 @@
|
|||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
class CodeForm(forms.Form):
|
class CodeForm(forms.Form):
|
||||||
code = forms.CharField(label='Code', max_length=8, required=True,
|
address = forms.CharField(label='Address', max_length=120, required=True,
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'placeholder': '123A56'}
|
attrs={'placeholder': '123 Main St.'}
|
||||||
))
|
))
|
||||||
email = forms.EmailField(label='Email', max_length=32, required=True,
|
email = forms.EmailField(label='Email', max_length=32, required=True,
|
||||||
widget=forms.TextInput(
|
widget=forms.TextInput(
|
||||||
attrs={'placeholder': 'jane@joe.com'}
|
attrs={'placeholder': 'jane@joe.com'}
|
||||||
))
|
))
|
||||||
|
code = forms.CharField(label='Code', max_length=8, required=True,
|
||||||
|
widget=forms.TextInput(
|
||||||
|
attrs={'placeholder': '123A56'}
|
||||||
|
))
|
||||||
|
@ -1,9 +1,37 @@
|
|||||||
{% extends 'common/master.html' %}
|
{% extends 'common/master.html' %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>Type In Your Code</h1>
|
<h1>Type In Your Code</h1>
|
||||||
<form action="{% url 'download_f' id %}" method="POST">
|
<form action="{% url 'download' %}" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
<div id="addrlist"></div>
|
||||||
|
<script>
|
||||||
|
const ADDR_BOX = document.getElementById('id_address');
|
||||||
|
const SEARCH_URL = '/download/search/';
|
||||||
|
const ADDR_LIST = document.getElementById('addrlist');
|
||||||
|
ADDR_BOX.oninput = async (e) => {
|
||||||
|
const ADDR_INPUT = e.target.value;
|
||||||
|
console.log(e.target.value);
|
||||||
|
|
||||||
|
let response = await fetch(SEARCH_URL + ADDR_INPUT);
|
||||||
|
let addresses = await response.json();
|
||||||
|
console.log(addresses);
|
||||||
|
ADDR_LIST.innerHTML = '';
|
||||||
|
for (address of addresses) {
|
||||||
|
let li = document.createElement('li');
|
||||||
|
let alink = document.createElement('button');
|
||||||
|
alink.innerText = address.address;
|
||||||
|
alink.onclick = function(e) {
|
||||||
|
console.log(e.target.innerText);
|
||||||
|
ADDR_BOX.value = e.target.innerText;
|
||||||
|
ADDR_BOX.readOnly = true;
|
||||||
|
}
|
||||||
|
li.appendChild(alink);
|
||||||
|
ADDR_LIST.appendChild(li);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in new issue