473,396 Members | 2,020 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,396 software developers and data experts.

Form trap problem

I want to ensure the users choose an item from a drop down list.
The preselected value is "Not Chosen"

Using script I cloned this from other working code, but it is broken
somewhere.

function checkform ( form )
{
if (form.ctsz.value == "Not Chosen") {
alert( "Choose Size or choose opt out" );
form.ctsz.focus();
return false ;
}
return true ;
}

Any help appreciated.

Garry Jones
Sweden

Oct 5 '06 #1
5 1194
"Garry Jones" <ga*********@morack.sewrote in message
news:eg**********@yggdrasil.glocalnet.net...
I want to ensure the users choose an item from a drop down list.
The preselected value is "Not Chosen"

Using script I cloned this from other working code, but it is broken
somewhere.

function checkform ( form )
{
if (form.ctsz.value == "Not Chosen") {
alert( "Choose Size or choose opt out" );
form.ctsz.focus();
return false ;
}
return true ;
}

Any help appreciated.
"broken somewhere" is not very helpful to us.

What does your form look like? Does it ihave:
<form onsubmit="checkForm(this)" ...>
and
<select name="ctsz" ...>
and
<input type="submit" ...>

Try using the Firefox browser to debug JavaScript.
http://www.getfirefox.com
Oct 5 '06 #2

McKirahan wrote:
"Garry Jones" <ga*********@morack.sewrote in message
news:eg**********@yggdrasil.glocalnet.net...
I want to ensure the users choose an item from a drop down list.
The preselected value is "Not Chosen"

Using script I cloned this from other working code, but it is broken
somewhere.

function checkform ( form )
{
if (form.ctsz.value == "Not Chosen") {
alert( "Choose Size or choose opt out" );
form.ctsz.focus();
return false ;
}
return true ;
}

Any help appreciated.

"broken somewhere" is not very helpful to us.

What does your form look like? Does it ihave:
<form onsubmit="checkForm(this)" ...>
That would need to be:

<form onsubmit="return checkForm(this)" ...>
--
Rob

Oct 5 '06 #3
"RobG" <rg***@iinet.net.auwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
What does your form look like? Does it ihave:
<form onsubmit="checkForm(this)" ...>

That would need to be:

<form onsubmit="return checkForm(this)" ...>
Good catch.
Oct 5 '06 #4
"broken somewhere" is not very helpful to us.

I have the checkform parameter and all values declared.

I have been using a java code script to test for an empty field.

This line of code results in the alert being triggered if the value is not
entered

if (form.deltport.value == "")

I have only ever tested for empty fields and assumed thought I could adapt
that code to test for a value.

I want to test for the value of an option from a "select" control.

Following the above example it should follow that this line of code

if (form.ctsz.value == "Not Chosen")

..... triggers an alert if the value is Not Chosen - but it does not work-

Greatful for any help in this matter.

Garry Jones
Sweden
Oct 6 '06 #5
"Garry Jones" <ga*********@morack.seskrev i meddelandet
news:eg**********@yggdrasil.glocalnet.net...
if (form.ctsz.value == "Not Chosen")
Sorry, I have been stupid (again).

I should not have tested for the text of the select control but the value
submitted by the option.

Now working, sorry to have wasted your time.

Garry Jones
Sweden
Oct 6 '06 #6

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

Similar topics

2
by: Carl Tribble | last post by:
I am using KeyPreview on the form to trap Function-keys. My form includes a datagrid. I am using the Form.KeyDown event to trap the keys and all works fine unless the datagrid is showing one or...
8
by: TNGgroup | last post by:
Hi, Question, I have a simple form and want to submit a selected value of a combo box. so my combo box is named "selectname" and my form has action="file.asp?" what do I have to put after the...
15
by: Dominic Tocci | last post by:
When I submit a form to an asp page, the request.form is not getting the data. This only happens on my local copy of IIS, and not on my web host. It's a simple request.form, so I know it's not a...
8
by: Emily Jones | last post by:
Very strange one this. Application written in Access 2000. Runs in 2003 at client's site, 2000 on my development system. FE/BE system. The app's startup form sets a few options, opens the...
2
by: David N | last post by:
Hi All, The OnLoad() event is invoked automatically when a form is being loaded. Do we have another event that is invoked automatically after a form has completed loading? Thanks.
17
by: Jim Little | last post by:
Hello, I'm driving myself crazy either because I'm missing something about ASP.NET, or what I'm trying to do simply can't be done. First, I am not using session variables to track state. My...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
3
by: Gavin | last post by:
Hi All I have a project that has 2 forms, the main form displays various sql data items and the second form is for editing / updating 1 particular table. I would like to refresh a dataset on...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
3
by: mtczx232 | last post by:
I have TabControls that Hold Forms on his TabPges (this make me easy to give ability to Designing each form in his IDE window). When form x is in middle of Edit Data Mode, I going to prevent:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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
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...

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.