473,624 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reset hidden variable after posting the form

14 New Member
I want to download the records of the output of search criteria to excel.
As the fields for search criteria are more than 20. I am submitting the form with POST method rather than GET.

On click of "Download2excel ", the hidden variable name1 is set to Yes. so i will check the condition in my code. Once the download is successful, I want to reset the variable.


Here is a sample structure of my code.

Expand|Select|Wrap|Line Numbers
  1.         <html>
  2.         <head>
  3.             <?php
  4.             if(trim($_POST['name1']) == 'yes') {
  5.                 header("Content-type: application/vnd-ms-excel");
  6.                 header("Content-Disposition: attachment; filename=$filename.xls");
  7.             }else {
  8.                 ?>
  9.         </head>
  10.         <body onload="tempFn()">
  11.  
  12.             <script language="javascript" type="text/javascript">
  13.                 function tempFn(){  
  14.                     global_search.name1.value = "";
  15.                 }
  16.                 function gs_download2xl_c() {
  17.                     document.getElementById('name1').value="yes";
  18.                     document.global_search.submit();
  19.                 }
  20.             </script>
  21.             <form name="global_search" id="global_search" action="test_1.php" method="POST">
  22.                 <input type="text" id="name1" name="name1" />
  23.                 <a  class="underline"  style="cursor: pointer" onclick="gs_download2xl_c();">
  24.                     Download2excel
  25.                 </a>
  26.             </form>
  27.                 <?php } ?>
  28.         </body>
  29.     </html>
As i am not executing the form after posting the form, i am not able to access the variable name1 is in it. I want to reset the variable name1.

I want to trigger the download, after submitting the form. As the records that are downloaded to excel should obey input search criteria.


Please suggest me a better procedure.
Jan 3 '11 #1
1 2154
RamananKalirajan
608 Contributor
On Submit are you reloading the same page or navigating to some other page? If you are reloading the same page means on body load use document.form.r eset() in ur code document.global _search.rese() or place this code before the </body> tag

ex:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. document.global_search.reset();
  3. </script>
  4. </body>
This will do when u r reloading the same page.

Thanks and Regards
Ramanan Kalirajan
Jan 4 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
558
by: Frank Rizzo | last post by:
Ok, this is probably so simple... Anyway, I'd like to pass a value in the hidden variable. I have code like this: <form...> <input type="Hidden" name="zzz" value="1"> ... </form> I want to replace the value with another when the page gets generated in
3
1958
by: TheNedMan | last post by:
Sorry for the repost, but I want to get to the bottom of this... From the Microsoft sample "How-To Create an Offline Application": Public Delegate Sub CustomersRowChangeEventHandler(ByVal sender As Object, ByVal e As CustomersRowChangeEvent) Public Event CustomersRowChanged As CustomersRowChangeEventHandler Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
19
10534
by: k.karthikit | last post by:
Hello all, In some hidden variable (<input type="hidden" name="hiddenId" value="test" /> ,i stored some value.I accessed the value "test" using var id = document.getElementById( 'hiddenId' ); It is working fine in IE. But in Mozilla Firefox , null value is returned.Is there any way to use hidden variables compatible to browsers......?
2
1624
by: graniteraju | last post by:
hi, can we set a hidden variable in a javascript.how do I do that? thanks,
2
2860
by: Norman Peelman | last post by:
From: "Norman Peelman" <npeelman@cfl.rr.com> Subject: Re: posting form data to two php scripts at once Date: Sunday, December 17, 2006 12:06 AM <one.1more@gmail.comwrote in message news:1166317725.715320.309280@80g2000cwy.googlegroups.com... Yes, you just have to call the second script from the first. You could try:
4
2309
by: jej1216 | last post by:
I'm pretty new to PHP and MySQL. I have managed to create a form that inserts data to MySQL and to create a form to search the DB. Now here is my problem. I am unsuccessful coding a hidden variable in an update page. Here is what I have: search_ir.php (this page searches the DB and lists incident_id's found. User then enters the incident_id of the row to update): .... <FORM METHOD="POST" ACTION="edit_ir.php"> <h3>Enter the Incident...
1
1491
by: rupeshnyadav | last post by:
How to access Hidden variable in Javascript declared in Content Page
11
7407
by: newbie | last post by:
i have a form in which a hidden field (initial value as '0', and my javascript set it to '1' when an event is trigged). In the same form, i have a reset field. But I realized that the hidden field is not reset to '0' when i push the reset button. If I simply change the node from "<input type="hidden" id='IsChanged' value='0'>" to "<input type="text" id='IsChanged' value='0'>" Everything is working as expected (the value is reset to '0'...
3
1591
by: mzmishra | last post by:
Hi, My page NewApplication.aspx consists of two user controls.one is Leftnavigation.ascx and otehr is AppDetails .ascx. I have one hidden variable "Test" in leftnavigation.ascx .I want to access the value of that hidden variable in my AppDetails.ascx page. Is it possible to do that?If yes please let me know how to do that.
4
7530
by: sgogula | last post by:
Hi, Could someone help me how to access a JSP hidden variable in Java Script? Here is my code: <script type="text/javascript"> var mnuItems = hdnItem] </script>
0
8251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8688
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7178
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6115
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4085
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.