Jump to content

javascript form submit help


lenerd3000

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/90864-javascript-form-submit-help/
Share on other sites

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>

 

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.