HTML_AJAX and formSubmit method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi List !
I'm playing around with HTML_AJAX PEAR module and came to a strange 
situation .
Consider following code :
<div id="target" style="border:solid 1px">&nbsp;This is where the result will 
be printed </div>
<center>
<form onsubmit="return !HTML_AJAX.formSubmit(this,'target');" 
action="/ajax/test1.php" method="post" name="frmTest" id="frmTest">
<div>
<table border="0">
	<tr>
		<td style="white-space: nowrap; background-color: #CCCCCC;" align="left" 
valign="top" colspan="2"><b><center>Login</center></b></td>
	</tr>
	<tr>
		<td align="right" valign="top"><b>User:</b></td>
		<td valign="top" align="left"><input name="user" type="text" /></td>
	</tr>
	<tr>
		<td align="right" valign="top"><b>Password:</b></td>
		<td valign="top" align="left"><input name="pass" type="password" /></td>
	</tr>
	<tr>
		<td align="right" valign="top"><b></b></td>
		<td valign="top" align="left"><input name="" value="Authenticate" 
type="submit" /></td>
	</tr>
</table>
</div>
</form></center>

Nothing special here. This actually works. 
HTML_AJAX.formSubmit(this,'target')
send the request and get what is printed from test1.php in the DIV with 
ID=target.
The problem is when i try to change the ID of the DIV with something else . 
Whatever ID i choose the script does not work as expected. It does not change 
the innerHTML of the div but the content of the FORM. 
Looking at the generated code from server.php i notice this:

formSubmit: function (form, target, customRequest)
    {
        if (typeof form == 'string') {
            form = document.getElementById(form);
            if (!form) {
                // let the submit be processed normally
                return false;
            }
        }
        if (typeof target == 'string') {
		//I think we MUST go here but it seems we don't...
            target = document.getElementById('target');
        }
        if (!target) {
	//I guess we enter here but we shouldn't.....
            target = form;
        }
..........................
The script seems to be OK but...
So generally this script works ONLY if the DIV is with ID=target and function 
called like this : HTML_AJAX.formSubmit(this,'target')
If i change the div with ID=alabala and call the script with : 
HTML_AJAX.formSubmit(this,'alabala') it does not work.
Any ideas ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux