473,756 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ 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(displa yrow) 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 1605
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
5750
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 align="center"><input class="button" type="button" onClick="location='draftedStory.asp';" value="Click to complete the drafted story"></p> <p align="center"> <input class="button" type="submit" value="Click to view your grade sheet" name="submit"> </p>
12
2529
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? i'm not sure of the best way to do this so help is very much appreciated; snide, smartass, unhelpful comments are useless. Please keep them to yourself.
11
1397
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 Transitional//EN"> <HTML> <HEAD> function checkAns( form )
2
2043
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" onSubmit="return(validateData(this))"> <input type="file" name="txtFileToUpload"> <input type="submit" name="btnAdd" value="Add" class="form_button"> </form> function checkFile(frm)
13
31466
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 supposed to check all the checkboxes, which it does (that's not rocket science ;), but the 'onchange' event does not get triggered.
1
4866
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 LimitAttach(form, file) { allowSubmit = false; if (!file) return; while (file.indexOf("\\") != -1)
2
37187
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 not possible. But I tested with the "input type="button" and the clicking of the event is not happened. Can any one tell me why. The code: <html> <body>
0
9152
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
9930
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
9571
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8569
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...
0
6410
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
4996
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...
1
3676
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 we have to send another system
2
3185
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2542
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.