0

Hi,

For some reason form submit is not working properly while I am using Ajax.

I want the result to be displayed on the same page. I am using Ajax for this, but when I submit the form, only text is being displayed rather than the actual value.

This is the sample code

//THE FORM
<div id="leftcoloumn">
    <form action="javascript:ajaxpage('files/search2.php', 'rightcolumn')" method="POST">
                            Email :<input type="text" name="email" value=""/>
                            <input type="submit" value="Submit">
    </form>
</div>
<div id="rightcolumn">
    <div style="clear: left; margin-bottom: 1em"></div>
</div>
//THE PHP FILE - search2.php
<?php
    $email = $_POST['email'];
    echo "The Email ID is :";
    echo $email;
?>
<html>
<body>
    <h1>Hello World</h1>
</body>
</html>

//Problem - search2.php only displays "The Email ID is :"
//It does not display the actual value entered in the text field i.e $email
When I have only search2.php in the form action field, then it displays $email buit on a separate page.
I want the result to appear on the same page i.e under

<div id="rightcolumn">
        <div style="clear: left; margin-bottom: 1em"></div>
    </div>
3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by harshm027
0

Instead of using,

<form action="javascript:ajaxpage('files/search2.php', 'rightcolumn')" method="POST">

why not try using

<form onsubmit="javascript:ajaxpage('files/search2.php', 'rightcolumn')" method="POST">

Edited by sasankasekhar: Sorry for the typo!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.