473,468 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

checking the value of a submit button

31 New Member
I have the following code:

Expand|Select|Wrap|Line Numbers
  1.  <script type="text/javascript"> 
  2.  
  3. function displayRow(){ 
  4. var ET = document.getElementById("ExpenseTable");
  5. var    row3 = document.getElementById("searchbutton");
  6.  
  7. If row3.value == 'search' {
  8. if (row2.value == 'Expenses') {
  9.          ET.style.display = '';
  10.          }
  11. }
  12. </script>
  13.  
  14.  
  15. <input type="submit" name="searchbutton" id="searchbutton" value='search' border="0" onClick="displayrow();return false;">
  16.  
  17.  
I want to do special things in Javascirpt function(displayrow) only if the value of submit button (searchbutton) equals to "search". ( Basically only if this button had been pressed)

right now every time I go to the form, the stuff in the javascirpt is happening but I want them to be place only if the search button had been pressed!

do you know how?
Jun 9 '08 #1
4 1586
F159753
31 New Member
Hi,

I have the following part in my code in ASP and javascript:


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript"> 
  2.  
  3. function displayRow(){ 
  4. var ET = document.getElementById("ExpenseTable");
  5. var row3 = document.getElementById("searchbutton");
  6.  
  7. If row3.value == 'search' {
  8. if (row2.value == 'Expenses') {
  9.          ET.style.display = '';
  10.          }
  11. }
  12. </script>
  13.  
  14.  
  15. <input type="submit" name="searchbutton" id="searchbutton" value='search' border="0" onClick="displayrow();return false;">

Basically in the Javascript part I want to check if the Searchbutton has been pressed or not! I don't know how to do that?!
Do you have any idea?

Regards,
FF
Jun 9 '08 #2
gits
5,390 Recognized Expert Moderator Expert
in case the function is called the search-button HAS BEEN clicked ... since you assigned the function to its onclick-handler. please explain your problem in more detail ...

kind regards
Jun 10 '08 #3
DrBunchman
979 Recognized Expert Contributor
Hi FF,

You can be absolutely sure that the code in your function will only run when your submit button is pressed if the only place you call this function is from the onclick event of the submit button.

Do you mean that the function appears to be called even if you don't click the submit button?

Dr B

PS Please can you start to use the # button when writing your posts to surround your code with code tags - it makes it much easier for everyone to read. Thanks.
Jun 10 '08 #4
jeffstl
432 Recognized Expert Contributor
From what you posted that javascript should not execute until the button is pressed.

How do you know its executing without the button? I don't believe that it would.

The only way that would be possible is if you placed that function call in the <body onload> tag.
Jun 10 '08 #5

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

Similar topics

1
by: monika | last post by:
hi ... I have an asp page which has 3 buttons. <p align="center"><input class="button" type="button" onClick="location='welStudent.asp';" value="Click to write a new story"></p> <p...
12
by: cruiserweight | last post by:
I've constructed this form so that if Javascript is disaabled it will show a typical <input type="submit"> button, BUT using the <noscript> tag. Why is this a problem and what's a viable solution?...
11
by: Bremse | last post by:
Hi! I've got problem. Everything works fine when on line !1! is just single entry in if statement. Why after putting "&&" script doesn't work? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...
2
by: mike | last post by:
I had a form like below that validated that a file was there before it would submit. <form name="attach" method="POST" action="run_this_pgm.cfm" enctype="multipart/form-data"...
13
by: aundro | last post by:
Hello, I've been looking on the web for a solution to this problem: I create a set of checkboxes, and 2 buttons: - one is labeled "All" - the other is labeled "None" Clicking "All" is...
1
by: gryffin | last post by:
im trying to do file extension checking but its not working :( i have the following in the head <script language="JavaScript"> extArray = new Array(".jpg", ".png", ".bmp"); function...
2
by: sathyashrayan | last post by:
Dear group, My question may be novice. I have seen codes where the isset() is used to test weather a user's session ($_SESSION) is set before entering a page. A kind of direct access to a page is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.