Page 1 of 1

Why is my page reloading?

Posted: Wed Apr 27, 2011 10:20 am
by nobdysfulz
I have inputted a bit of code on my homepage that is pretty much working. The only thing is when a selection is made, it reloads the page to show the next options. I want it to stop doing that but I have no clue how. Can anyone help?

http://jay.printafix.com

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Order by MODEL</title><meta name="DESCRIPTION" content="">
        <link href="http://connectingtoarandomserver.com/api_external/inner.css" rel="stylesheet" type="text/css" />
        <link href="http://connectingtoarandomserver.com/api_external/jquery.css" rel="stylesheet" type="text/css" media="screen">
        <script type="text/javascript" src="http://connectingtoarandomserver.com/api_external/jquery.js" language="javascript"></script>
        <script src="http://connectingtoarandomserver.com/api_external/jquery_002.js" type="text/javascript"></script>
        <script type="text/javascript" src="http://connectingtoarandomserver.com/api_external/swfobject.js"></script>
        <script type="text/javascript" src="http://connectingtoarandomserver.com/api_external/encode64.js" language="javascript"></script>
        <!-- PLEASE DO NOT CHANGE THIS -->
        <script type="text/javascript" src="http://connectingtoarandomserver.com/api_external/web_api.js" language="javascript"></script>
        <!-- END -->
    <body MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" RIGHTMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0">       
        <form action="" method="post" enctype="multipart/form-data" class="form" name="form" onSubmit="return validateForm()">
            <table cellspacing="0" cellpadding="0" border="0" style="width:100%;border-collapse:collapse;"></table>
            <table width="496" border="0" align="center" cellpadding="4" cellspacing="6">
                <tr>
                    <td width="150">EMAIL <span class="required">*</span></td>
                    <td >
                        <!-- PLEASE CHANGE THIS to YOUR IMAGES-->
                        <input id="rcemail" name="rcemail" class="textBox" type="text" value="<?=$_REQUEST["rcemail"]?>">
                        <!-- END-->
                    </td>

                </tr>
                <tr>
                    <td>IMEI <span class="required">*</span></td>
                    <td>
                        <!-- PLEASE CHANGE THIS to YOUR IMAGES-->
                        <input maxlength="15"  id="imei" name="imei" class="textBox" type="text" value="<?=$_REQUEST["imei"]?>">
                        <!-- END-->
                    </td>
                </tr>
                <td>COUNTRY <span class="required">*</span></td>
                <td>
                    <!-- PLEASE DO NOT CHANGE THIS -->
                    <div id="coun">
                        <?php
                        $a = file_get_contents("http://connectingtoarandomserver.com/api_external/web_api_get_info.php?id=245&r1=4&opt=3&sel=".$_REQUEST["country"]);
                        echo ($a);
                        ?>
                    </div>
                    <!-- END -->
                </td>


                <tr>
                    <td>OPERATOR <span class="required">*</span></td>
                    <td ><div id="opr">
                            <!-- PLEASE DO NOT CHANGE THIS -->
                            <?
                            if($_REQUEST["country"]=="")
                                print('<select name="operator" id="operator" class="textBox"><option value="">Select operator</option></select>');
                            else
                                $b = file_get_contents("http://connectingtoarandomserver.com/api_external/web_api_get_info.php?id=245&r1=4&opt=1&q=".$_REQUEST["country"]."&sel=".base64_encode($_REQUEST["operator"]));
                            echo ($b);

                            ?>

                            <!-- END -->
                        </div></td>

                </tr>
                <tr>
                    <td>MODEL <span class="required">*</span></td>
                    <td >
                        <!-- PLEASE DO NOT CHANGE THIS -->
                        <?
                        if($_REQUEST["country"]=="" && $_REQUEST["operator"]=="" )
                            print('<select name="model_val" id="model_val" class="textBox"><option value="">Select model</option></select>');
                        else
                            $c = file_get_contents("http://connectingtoarandomserver.com/api_external/web_api_get_info.php?id=245&r1=4&opt=2&q=".base64_encode($_REQUEST["operator"])."&cnt=".$_REQUEST["country"]);
                        echo ($c);
                        ?>
                        <!-- END -->
                </tr>


                <!-- PLEASE DO NOT CHANGE THIS -->
<input type="hidden" name="r1" id ="r1" value="1" >
<input type="hidden" name="api_key" id ="api_key" value="NDgzYjdjOTVmZTliNGQzOTNjY2RmZTJiODkwNmM2MDYxZTVkZjhlNA==">
                <!-- END -->

                <tr>
                    <td></td>
                    <td align="right">
                        <!-- PLEASE CHANGE THIS to YOUR IMAGES-->
                        <input type="submit" value="Submit Order" name="submitbtn" class="submit" style="margin: 0;" />
                        <!-- END-->
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>

Re: Why is my page reloading?

Posted: Wed Apr 27, 2011 4:03 pm
by kristen
The reload is caused by javascript, not PHP.

Re: Why is my page reloading?

Posted: Fri Apr 29, 2011 2:13 am
by Gopesh
Hi,Use AJAX for stopping reloading or refreshing the page........

Re: Why is my page reloading?

Posted: Fri Apr 29, 2011 8:06 am
by fugix
yes you will have to look into using ajax...which sends http request without the need to reload the page

Re: Why is my page reloading?

Posted: Fri Apr 29, 2011 4:54 pm
by califdon
It's not really javascript, it's simply HTML. Your form shows action="", which means "reload this page". The comments about using Ajax are correct.