I have two php pages. One controls the form while the other displays a table. What my question is that I have spinner in the form which determines the number of questions, whatever number is displayed on that spinner, when the user submits it should display that same number of rows in the table.
for example if the Spinner = 25,then it should display 25 rows in the table and stating in the rows 1,2,3,4…up to 25 for the Question Id (<td class=“qid”>).
My problem is that I am getting an undefined index error everytime stating Notice: Undefined index: txtQuestion… on line 42. I don’t know why I am getting this error though as it should be able to find the index but for some strange reason it can’t find the index. Do you know why?
Below is code for the spinner and submit button (create_session.php)
But like I mentioned in one of your other threads, in the past you have copy and pasted your posts on multiple websites so you probably have already got the solution if you have again posted a copy of your post on other websites.
I described in your thread here how to go about debugging your code.
function openSessionPopup() {
window.open("QandATable.php",
'window');
}
You’re not SUBMITTING the form data. You’re just opening a new window. So of course you’re getting an undefined index when looking for form data… there’s no form data being sent.
It will post the form, when it’s told to submit. You dont have a submit button, and your javascript on the button you have does not submit the form, so… how exactly is the page supposed to know when you want to submit data?
Ok I understand now, Thank You :), but problem is though if I change it from a button to a submit, whenever I click on the submit button, it checks for validation and submits the form and opens up the page togeether, the reason it was a “button” type was so that if the button was clicked on, it will check for validation first, if validated then it will open up window else if not it will stay on same page and dsplay validation messages where neccesary
How can you even ask that when the undefined index error you posted is telling you no form data is being submitted.
You need a submit button and an onsubmit event handler on your <form>. The event handler validates the form data. If any form data is invalid, the event handler needs to return false to the form and so supress the form submission. If all form data is valid, then the event handler returns true to the form thus allowing the form data to be submitted.