lenerd3000 Posted February 13, 2008 Share Posted February 13, 2008 i have a form and a select. everytime i change the select value should submit the form auto but its not firing.. heres my code: <form action='index.php' method='post' name='submitForm' id='submitForm'> <select name='campaign' id='campaign' onchange="javascript: document.getElementById('submitForm').submit();"> <option value='1'>1</option> <option value='2'>2</option> </select> can u show me whats lacking in my code? i have already use: <select name='campaign' id='campaign' onchange="document.getElementById('submitForm').submit();"> <select name='campaign' id='campaign' onchange="form.submit();"> <select name='campaign' id='campaign' onchange="submitForm.submit();"> but nothings happen. Quote Link to comment Share on other sites More sharing options...
nogray Posted February 13, 2008 Share Posted February 13, 2008 Make sure you dont have another element with the id "submitForm", the form you posted seems to work just as excepected. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action='index.php' method='post' name='submitForm' id='submitForm'> <select name='campaign' id='campaign' onchange="javascript: document.getElementById('submitForm').submit();"> <option value='1'>1</option> <option value='2'>2</option> </select> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
lenerd3000 Posted February 15, 2008 Author Share Posted February 15, 2008 that's rely confuse me... i know its syntax is correct but i can't make it work. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 15, 2008 Share Posted February 15, 2008 Why don't you try this and see how it works out for you: <form action='index.php' method='post' name='submitForm' id='submitForm'> <select name='campaign' id='campaign' onchange="document.submitForm.submit();"> <option value='1'>1</option> <option value='2'>2</option> </select> </form> Quote Link to comment Share on other sites More sharing options...
nogray Posted February 15, 2008 Share Posted February 15, 2008 can you post the URL, or the complete HTML file. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.