There is an index.php page with the created form:
<?php require_once("class.php"); echo "test"; echo " <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <title>Test Alphabetics</title> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,300' rel='stylesheet' type='text/css'> <style> body { font-family: Arial, sans-serif; } .section { margin: 20px; } button { padding: 5px 16px; border-radius: 4px; } button#changeQuota { background-color: yellow; } button#transfer { } button#buyTicket { background-color: #98fb98; } button#refundTicket { background-color: pink; } </style> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script> <link href='./app.css' rel='stylesheet' type='text/css'> <script type='text/javascript' src='./app.js'></script> </head> <body> "; $task = new Form("process.php", "Отправить данные"); $task->addFieldName("#f1"); $task->addFieldName("#opt"); $task->addFieldName("#f2"); $task->addFieldName("#exec"); $task->addFieldName("#res"); $task->displayForm(); echo " </body> </html> "; ?>
The form is created normally, everything is in place, the selectors are also in place.
Result html:
<!DOCTYPE html> <html> <head> <meta charset='utf-8'> <title>Test Alphabetics</title> <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,300' rel='stylesheet' type='text/css'> <style> body { font-family: Arial, sans-serif; } .section { margin: 20px; } button { padding: 5px 16px; border-radius: 4px; } button#changeQuota { background-color: yellow; } button#transfer { } button#buyTicket { background-color: #98fb98; } button#refundTicket { background-color: pink; } </style> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script> <link href='./app.css' rel='stylesheet' type='text/css'> <script type='text/javascript' src='./app.js'></script> </head> <body> <div class='section'><h2>Введите данные</h2></br> <input type='text' id='#f1'/></br> <select required id='#opt'><option value='1'>*</option> <option value='2'>/</option> <option value='3'>+</option> <option value='4'>-</option></select></br> <input type='text' id='#f2'></br> <button id='#exec'>Отправить данные</button> <span id='#res'></span></br> </body> </html>
App.js is connected to the index with the following content:
$(document).ready(function () { console.log("test"); $("#f1").html("3"); $("#res").html("Whoa!"); //Warmig up UI $("#exec").click(function() { var f1 = $("#f1").val(); var f2 = $("#f2").val(); var opr = $("#opr"); Calc(f1,f2,opr); console.log("test click"); }); function Calc() { console.log(f1); console.log(f2); console.log(opr); $.post( "/process.php", { f1 : f1, f2 : f2, opr : opr }, onAjaxSuccess ); function onAjaxSuccess (data) { var r=data; console.log(data); result=r.result; console.log(result); } } });
Nor does any selector work. Values are not set, the function does not work, etc. At all.
I would be very grateful if someone tells you how to solve the problem.
UPD - changed, now. Val () displays the element code, for example, A should display the value ..