473,404 Members | 2,170 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.

Javascript error capture

HI All,

I'm in need of a lttle help as my javascript is almost non-existent.
Below is some code I have that alerts the user if they have not
selected a radio button. It also contains code alerting the user to
what they have selected.

I would like just the alert if they don't select a radio button but for
the life of me I'm unable to edit the javascript.

snip..............................
<script type="text/javascript">

function checkRadio(field)
{
for(var i=0; i < field.length; i++) {
if(field[i].checked) return field[i].value;
}
return false;
}

function checkForm3(form)
{
if(radioValue = checkRadio(form.pagetemplatename)) {
alert("You selected " + pagetemplatename);
} else {
alert("Incomplete Form: You must select a page layout to
continue");
}
return false;
}

</script>
snip..............................

and form code

snip..............................

<form action="index.cfm?fuseaction=page1" method="post"
action="/javascript/validate/" onSubmit="return checkForm3(this);">

this is the radio button:

snip.............................
<cfoutput>
<input type="radio" name="pagetemplatename"
value="#currentTemplate.objectID#" <cfif
isDefined("form.pagetemplatename") and form.pagetemplatename eq
currentTemplate.objectID> checked=checked</cfif>>
&nbsp;#currentTemplate.objectName#<br />
</cfoutput>
snip..............................

Thanking you in advance

Trevor

Jan 27 '06 #1
1 1898
I'll answer my own question after finding another solution in case
someone else is searching for a similar problem.

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

function validate() {

var theMessage = " ATTENTION";
var noErrors = theMessage
var radioCheck = false;
for (i = 0; i < document.form1.pagetemplatename.length; i++) {
if (document.form1.pagetemplatename[i].checked)
radioCheck = true; }
if (!radioCheck) {
theMessage = theMessage + "\nYou need to select a page layout";
}
if (theMessage == noErrors) {
return true;

} else {
alert(theMessage);
return false;
}
}
// End -->
</script>

the form has:

<form action="index.cfm?fuseaction=page1" name="form1" method="post"
onSubmit="return validate(this);">

Radio button name I'm using name="pagetemplatename"

HTH someone.

Jan 27 '06 #2

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

Similar topics

3
by: Daniel Borden | last post by:
Big hello to my fellow programmers - I'm new to javascript and PHP and I am wondering if there is a method or function to capture a 404 error in the event a particular html file cannot be found. I...
4
by: binnyva | last post by:
Hello Everybody, I am writing an interactive tutorial for JavaScript. I created a text box into which the users can input javascript commands. On pressing a button, these commands will be...
2
by: UDBDBA | last post by:
Hi all: We see these errors when starting capture. The version we are running is UDB V8 FP8 64bit AIX 5.2 ML4. When would capture keep erroring with this LSN? Any ideas? ...
8
by: Dave | last post by:
Hello all, I have been able to use a Javascript alert box in my vb.net web application, for example: Dim msg As String = "Hello, world." Dim alertScript As String = "<script...
8
by: Nehmo | last post by:
When a page has a JavaScript "link" to a video, like http://www.msnbc.msn.com/id/10478942/ . How do you get the URL of the actual video? Isn't it in the source somewhere? -- )|:__ Nehmo __:|(
0
by: rahul | last post by:
i have found following error log for service at source db after it went down 2007-02-22-16.07.50.843000 <CWorkerMainASN0100I CAPTURE "ASN" : "WorkerThread". The Capture program initialization...
9
by: Hirru | last post by:
Hi................., i want to capture event from vb dll file in javascript,actually i can already access all the function of that dll from javascript but i don know how to capture event raised by...
19
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? ...
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?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.