Reputation: 33
EDIT: Resolved. I didn't add quotations!
I am trying to update a form's action depending on the value inside a select box using JavaScript.
So far I have:
<form name="newStudent" method="POST" onsubmit=newStudent.action = document.newStudent.proceed.value>
and further down in my code:
<select name="proceed">
<option value="newSchedule.php">add student's schedule</option>
<option value="newStudent.php">add another student</option>
<option value="staff.php">staff page</option>;
Nothing happens when the submit button is pressed. What am I doing wrong? The current page is newStudent.php so the form should redirect to newSchedule.php since it is selected.
Upvotes: 0
Views: 1133
Reputation: 96
try this:
<form name="newStudent" method="POST" onsubmit="this.action = document.newStudent.proceed.value">
Upvotes: 0
Reputation: 700342
The attribute value contains spaces, so you need quotation marks around it:
<form name="newStudent" method="POST" onsubmit="newStudent.action = document.newStudent.proceed.value">
Upvotes: 2