I have created a simple page. In that I have a VIEW button so on clicking that view button I am able to open a popup window. So I want a button called "EDIT" to be inside the popup window and on clicking that EDIT button it should edit the JSON data which is coming from the URL in the popup window.
**
This is my Base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Operations Performed</title>
<script>
function calc()
{
var n1 = parseFloat(document.getElementById('n1').value);
var n2 = parseFloat(document.getElementById('n2').value);
var oper = document.getElementById('operators').value;
if (oper === '+'){
document.getElementById('result').value = n1+n2;
}
if (oper === '-'){
document.getElementById('result').value = n1-n2;
}
if (oper === '*'){
document.getElementById('result').value = n1*n2;
}
if (oper === '/'){
document.getElementById('result').value = n1/n2;
}
}
</script>
</head>
<body bgcolor='cyan'>
{% block content %}
{% endblock %}
</body>
</html>
**
This is my Home.html
{% extends 'base.html' %}
{% load static%}
{% block content %}
<h1>Hello {{name}}...!!!></h1>
<form action="add" method="POST">
{% csrf_token %}
<select id="operators">
<option value="+">Addition</option>
<option value="-">Subtraction</option>
<option value="*">Multiplication</option>
<option value="/">Division</option>
</select><br>
<br>
<br>
<br>
<br>
Enter 1st no: <input type="text" name="num1" value='{{val1}}' id="n1"><br>
Enter 2nd no: <input type="text" name="num2" value="{{val2}}" id="n2"><br><br>
<input type="submit" onclick="calc(); return false;" />
<br><br>
<input type="text" id="result">
<input type="submit" value="view" onclick= "window.open('http://10.33.0.112/test.json','_blank','height=400,width=400'); return false;"/>
{% endblock %}
This is my views.py
from django.shortcuts import render
from django.http import HttpResponse
from django import forms
# Create your views here.
def home(request):
return render(request,'home.html',{'name':'Cisco'})
def add(request):
res = 0
if request.method == 'POST':
val1 = int(request.POST['num1'])
val2 = int(request.POST['num2'])
res = val1 + val2
return render(request,'home.html',{'Result':res,'val1':val1,'val2':val2})
This is my urls.py
from django.urls import path
from . import views
urlpatterns=[
path('',views.home,name='home'),
path('add',views.add,name='add'),
]
I have created this page as shown in the photo.So when i am clicking this view button i am able to open popup window with json data coming from some url. But i want a EDIT button inside this popup window so that on clicking that edit button i will be able to edit the data inside the json.