Passing Variables To Onsubmit using a FORM, Trying to pass a FORM input to onsubmit and not working |
Passing Variables To Onsubmit using a FORM, Trying to pass a FORM input to onsubmit and not working |
voodoo98_ca |
Mar 25 2009, 10:22 AM
Post
#1
|
Group: Members Posts: 1 Joined: 25-March 09 Member No.: 8,152 |
Hi There,
First off I wasnt sure which category I should put this problem since its using FORMS, and javascript. So I decided to be a bit more generic and put it under HTML. Anyhow, I'm trying to pass a textual input into a procedure that I want to run when the user hits the enter key. Basically the screen waits for the user to enter in the name for a new database to be entered and then that is passed to mysql procedure that will create this new database however, the below code does not work. Im totally stumped. Can someone please shed some light on what Im doing wrong?? echo "<span><form action=\"index.php\" onsubmit=\"ajax_request('create_db_mysql.php');\" method=\"post\"></span>"; echo "<span><input type=\"text\" name=\"create_db_name\"></span>"; echo "<span></form></span>"; Thanks. |
pandy |
Mar 25 2009, 12:07 PM
Post
#2
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
I move it to client side scripting.
|
Christian J |
Mar 25 2009, 02:31 PM
Post
#3
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
If it's the javascript/AJAX that doesn't work you may have to show the script for us. Also try adding a "return false" after the JS function call to suppress the form from submitting to index.php:
CODE onsubmit="ajax_request('create_db_mysql.php'); return false;" BTW the following looks like PHP: CODE echo "<span><form action=\"index.php\" onsubmit=\"ajax_request('create_db_mysql.php');\" method=\"post\"></span>"; echo "<span><input type=\"text\" name=\"create_db_name\"></span>"; echo "<span></form></span>"; but the resulting HTML is invalid due to improper nesting of elements (removing all the SPAN tags should fix that part). |
Lo-Fi Version | Time is now: 25th April 2024 - 11:19 PM |