0

So I'm trying to pass simple form data from my file ResName.html

<head>
<form action="file:///E:/programs/portAppJavascript.html" method="post">
    Name: <input id = 'name'>
    <br>
    Number of Reservations: <input type="text" id ='resseats' name="resseat">
    <input type='submit' value="Choose Seats">

</form>

</head>`

to my file portAppJavascript.html. I'm just trying to pass the number of reservations to a js variable below.

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

var isClicked = false;
var counter = 0;
var numSeatsBought = <?php $_GET['resseat'] ?>; //window.location.search; //change to get from other     html page
var seatArray = new Array();

function clicked(clicked_id){

////////////////
var links = document.head.getElementsByTagName('link');
for(var link in links){
    if(links.hasOwnProperty(link)){
        var l = links[link];
        if(l.rel === 'canonical'){
          alert(l.href);
    }
}
}

Why is it not passing the number to the javascript variable? How can I fix this? numSeatsBought is the variable that's not receiving the data correctly.

1 Answer 1

2

There are a few problems here:

  1. Your form uses the POST method, but in the next file you check for a GET variable. You should use $_POST['resseat'] there;
  2. You are posting to a file, not a script on a server like http://localhost/... so there is no web-server involved and your php will not be processed;
  3. The script you are posting to, has the .html extension so the php will probably not be processed even if you fix the second problem.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.