Link to home
Start Free TrialLog in
Avatar of APD Toronto
APD TorontoFlag for Canada

asked on

JS Reload without Query String

Hi Experts,

Using JS how can i Reload tthe same page without Query String
Avatar of Nathan Riley
Nathan Riley
Flag of United States of America image

You can do it like this:

<!DOCTYPE html>
<html>
    <body>
        <a href="#" id="reload">Click to reload without query string</a>

        <script>
            document.getElementById("reload").onclick = function() {reload()};

            function reload() {
                window.location = window.location.href.split("?")[0];
            }
        </script>
    </body>
</html>

Open in new window


Working demo
Avatar of APD Toronto

ASKER

For some reason its not truncating.  I do see my dummy alert('p');, but the query string remains...

    <html>

    <head>
      <meta name="robots" content="index,follow" />

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

      <meta name="google-site-verification" content="Z5bx5dQBjZlorshNdQSqwhgaAJesfaM561PZSjeYMnY" />

      <meta name="y_key" content="95b4b6bb4fe3c93f" />

      <meta name="description"
     content="we take pride in offering the highest quality tour at the best price,whether our legendary Toronto hop-on hop-off ticket with a free Harbour and Islands Cruise or our famous Niagara Falls day trip" />

      <meta name="keywords"
     content="bus company, bus tours, city sightseeing, city tours, cruise, cruises, event
    events, hotel, restaurant, restaurant listings, shopping, shops, shop in, niagara, niagara falls, sightseeing, sightseeing tours, things to do, tour of, touring, tourist, tourist attractions, tourist information, tours, travel, travel guide, trips, vacation, what to do" />



      <link href="../css/navigation.css" rel="stylesheet" type="text/css" />

    <title>CitySightseeing Niagara Falls</title>
    </head>

    <body bgcolor="#6600CC">
        <center>
	<table border="0" width="1024">
		<tr>
			<td>
			<table border="0" width="100%">
				<tr>
					<td width="495" valign="top">
					<img border="0" src="../images/CSST_Logo-small.jpg" width="463" height="174" align="right"></td>
					<td width="555" valign="top">
					<img border="0" src="../images/CSSN_Logo-small.jpg" width="455" height="173"></td>
				</tr>
			</table>
			<p align="center"><u><font color="#FFFF00" size="7"><b>
			Administration</b></font></u></p>
			<p></p>



    <center>
        &nbsp;<table border="0" width="100%" cellspacing="0" cellpadding="5">
                <tr>
                        <td bgcolor="#5CC7EE"><b><font face="Arial" size="5">
                        CSST &amp; CSSN Administration</font></b></td>
                </tr>
                <tr>
                        <td bgcolor="#FFFFFF">&nbsp;<p><b><i><font face="Arial">

        
    <link href="css/gratuity.css" rel="stylesheet" type="text/css" />
    <link href="utilities/jquery.calendars.picker.css" rel="stylesheet" type="text/css" />
    
    <form action="gratuity2.php" method="get">
        <div id="divSearchArea">
            
            <div id="divConfGroup" class="divSrchBox">
                
                <div class="divSearchCrit">
                    
                    <label for="txtConf">Conf #</label>                    
                    <input type="text" id="txtConf" name="txtConf"
                           value="" />
                    
                </div>
                
                <div class="divSearchCrit">
                    
                    <label for="txtGroup">Group Name</label>                    
                    <input type="text" id="txtGroup" name="txtGroup" 
                           value="" />
                    
                </div>
            
            </div>
            
                <div id="divCharterDateNo" class="divSrchBox">


                    <div class="divSearchCrit">

                        <label for="txtChartDate">Charter Date</label>                                      
                        <input type="text" id="txtChartDate" name="txtChartDate" readonly="readonly" 
                           value="" />

    <!--Common JS Libraries, also needed for Date Picker -->
    <script type="text/javascript" src="utilities/jquery.js"></script>
    <script type="text/javascript" src="utilities/jquery.plugin.js"></script>

        <!--JS=Specific to Date Picker Control-->
<script type="text/javascript" src="http://localhost/CSST_subdomains/admin.citysightseeingtoronto.com//utilities/jquery.calendars.min.js"></script>
<script type="text/javascript" src="http://localhost/CSST_subdomains/admin.citysightseeingtoronto.com//utilities/jquery.calendars.plus.min.js"></script>
<script type="text/javascript" src="http://localhost/CSST_subdomains/admin.citysightseeingtoronto.com//utilities/jquery.calendars.picker.min.js"></script>
<script type="text/javascript">
   $(function() {
        //retrieve default commands
        var todayCommand = $.extend(true, {}, $.calendarsPicker.commands);

        //override only "today.action"
        todayCommand.today.action = function(inst){
                //show popup
                $.calendarsPicker.showMonth(this);

                //update value of text field
                $(this).val( $.calendars.newDate() );

                // uncomment the following line if you want the popup to auto-hide
                $.calendarsPicker.hide(this);
                
                //Move focus out
                $(this).blur();
            };

         //use the altered commands saved in "todayCommand" to override the default settings for each text control
            $("#txtChartDate").calendarsPicker(
            {commands:todayCommand, 
                          firstDay: 1, dateFormat: 'yyyy-mm-dd'}); 
        });
  
</script>
                    
                    </div>

                    <div class="divSearchCrit">

                        <label for="txtChartNo">Charter #</label>                    
                        <input type="text" id="txtChartNo" name="txtChartNo" 
                           value="69" />

                    </div>


                </div>

                <div id="divGratuity" class="divSrchBox">

                    Show records with gratuity that has been:

                    <div class="divSearchCrit">
                                            <input type="radio" name="optGratuity" id="optPaid" value="paid"
                               >
                            <label for="optPaid">Paid</label> <br />

                        <input type="radio" name="optGratuity" id="optOwing" value="owing"
                               >
                            <label for="optOwing">Owing</label> <br />

                        <input type="radio" name="optGratuity" id="optBoth" value="both"
                               checked>
                            <label for="optBoth">Paid &amp; Owing</label> <br />

                    </div>

                </div>

            <div id="divSubmitReset">
                                
                <button id="btnSubmit" type="submit">Search</button> &nbsp; &nbsp; &nbsp;
                <button id="btnReset" onclick="resetForm();">Reset</button>
          
            </div>
            
            <div class="divSearchCrit hidden">
                
                <label for="txtPage">txtPage</label>                    
                <input type="text" id="txtPage" name="txtPage" 
                           value="1" />

            </div>
            
        </div>        
    </form>
    


        </font></i></b></p>
					<span id="siteseal">
                    		<p>&nbsp;</td>
                		</tr>
			</table>
			</center>
			</div>
		<!--end ProgressBar-->
            <!--end NavigationMenu2-->
        	</p>
    	</tr>
	</table>
    </center>
    </body>

</html>
                                        

<script type="text/javascript">
    
 //   $(document).on('ready', function(){
        function resetForm(){
            alert('p');
            window.location = window.location.href.split("?")[0];// 'gratuity2.php' + ' ';
        }
   // });
</script>

Open in new window

It should happen when you click Reset.
ASKER CERTIFIED SOLUTION
Avatar of Nathan Riley
Nathan Riley
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you
No problem, glad it worked out!

Noticed you're not using any basic helpers on your CSS.

Check out Bootstrap. Will make your life a lot easier :)