Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Submit in onChange-event

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Submit in onChange-event

Postby trompie » Thu May 08, 2003 4:23 am

Simplified, I have a form with a textfield and a submit button. When the value of the textfield is changed, I want to call a php-function in the onChange-event that first displays a (hidden) textfield and then submits the form. I tried this:

<?
function clicked()
{ echo"<input type=hidden name=txthidden value=pipikaka>";
window.document.form1.submit();
}
?>
...
<form name=form1 action="selected.php" method=post>
<input type=text name=txt1 value=1 onChange="<? clicked(); ?>" >
<input type=submit value=submit>
</form>
...
trompie
New php-forum User
New php-forum User
 
Posts: 4
Joined: Mon Apr 07, 2003 4:24 am

Re: Submit in onChange-event

Postby WiZARD » Thu May 08, 2003 4:38 am

you have a very big mistake!!!
first in onChange you may place only JavaScript not more. By the way you may see code youre page
change at
Code: Select all
<?
function clicked()
{echo("onChange=\"window.document.form1.submit();\"");}
?>
...
<form name=form1 action="selected.php" method=post>
<input type=text name=txt1 value=1 onChange="<? clicked(); ?>">
<input type=hidden name=txthidden value=pipikaka>

<input type=submit value=submit>
</form>
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.