473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

onclick doesn't work

Hi,

I've this piece of code which does not work at all.
Can anyone point out my mistake?

I've 2 buttons. History button will call verifyFields() function and
lead to
different page for processing. verifyFields() is working fine and so
does the
history() function.

But,

the other save button doesn't work. It's supposed to call the save()
function and before executing the action, it will perform a check by
executing
checkFormFields(). However it does not execute these statements:
--------------------------------------------------------------------
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecor d.asp?action=check";
--------------------------------------------------------------------
The links above have been verified and it's working.


<SCRIPT LANGUAGE="JavaScript">
<!--

function checkFormFields()
{
if(!isNumber(ListForm.destination.value))
{
alert("Destination must not contain numbers at all.");
ListForm.destination.focus();
return false;
}
return true;
}

function history()
{
document.ListForm.target="adhoc";
document.ListForm.action="ListByOrigin.asp?action= check";
}

function save()
{
if (checkFormFields() ) //doesn't execute these 2 lines.
{
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecor d.asp?action=check";
return true;
}
}
//-->
</script>
<form action="" method="post" name="ListForm" onSubmit="return
verifyFields();">

<input name="submit" type="submit" value="History"
onClick="history()">

<input name="submit" type="submit" id="submit" value="Save"
onClick="return save();">

</form>
Jul 23 '05 #1
2 2393
kelvin wrote:
Hi,

I've this piece of code which does not work at all.
Can anyone point out my mistake?

I've 2 buttons. History button will call verifyFields() function and
lead to
different page for processing. verifyFields() is working fine and so
does the
history() function.

But,

the other save button doesn't work. It's supposed to call the save()
function and before executing the action, it will perform a check by
executing
checkFormFields(). However it does not execute these statements:
--------------------------------------------------------------------
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecor d.asp?action=check";
--------------------------------------------------------------------
The links above have been verified and it's working.

<SCRIPT LANGUAGE="JavaScript">
<script type="text/javascript">
<!--
<!-- Not needed.
function checkFormFields()
{
if(!isNumber(ListForm.destination.value))
Where is "isNumber()" defined? It's not in the source you provided. As a result any
attempt to call isNumber() will result in a syntax error.
{
alert("Destination must not contain numbers at all.");
ListForm.destination.focus();
return false;
}
return true;
}

function history()
{
document.ListForm.target="adhoc";
document.ListForm.action="ListByOrigin.asp?action= check";
}

function save()
{
if (checkFormFields() ) //doesn't execute these 2 lines.
As indicated above, checkFormFields() contains a call to an undefined function.
{
document.ListForm.target="origin";
document.ListForm.action="ListByOrigin_updaterecor d.asp?action=check";
return true;
}
You use "return save()" on the form, but save() does not always return a value, you should
add "return false;" here. It may work without it, but it's a good habit to have functions
that are supposed to return something always explicitly return something.
}
//-->
//--> Not needed
</script>

<form action="" method="post" name="ListForm" onSubmit="return
verifyFields();">

<input name="submit" type="submit" value="History"
onClick="history()">

<input name="submit" type="submit" id="submit" value="Save"
onClick="return save();">

</form>


--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2
hi Grant,

I've done some changes and it works now.
Thank you for your advise.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Erik | last post by:
I need to submit a form using a hyperlink, and I need to pass a variable associated with that hyperlink. Example: I have a page where employees enter event information, and they are supplied a...
2
by: mscir | last post by:
I was calling a function in a js file from an image onClick event, but someone still using Netscape 4 (!) complained that it didn't work. I read that img onClick doesn't work in Netscape 4, so...
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
3
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement...
10
by: Noozer | last post by:
Is it possible to detect where on a page the click occurred when the OnClick event of the BODY tag is fired? Thx
10
by: Eric-Sebastien Lachance | last post by:
Hey there, I decided to just create a 100% height and width div that filled the space over a background header image, and add an onclick event to redirect to the my index... Doesn't seem to work...
13
by: pagates | last post by:
Hello All-- I'm having a problem getting an onclick event to work. Here is my setup: I have an external JavaScript file, a master page that registers the javascript as an external file, and a...
11
by: Daz | last post by:
Hello everyone. I am sure the answer to my question is simple, but I can't seem to dynamically add an onClick event to my script. I have a table which is generated dynamically, I am just...
3
by: Michael_R_Banks | last post by:
I'm trying to dynamically build a table that allows users to remove rows when they click a corresponding button. For some reason, whenever I add the button to the table, it never fires the onclick...
20
by: Charles | last post by:
Hello, On my web site, I have a <selectdrop-down menu that allows to show/ hide divs: http://tchernobyl.dreamhosters.com - The problem is that it doesn't work in IE7 (only tested in Opera and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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,...

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.