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

[Javascript] Fields required

Hi all.

I have this web page:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4.  
  5. </head>
  6.  
  7. <body>
  8.  
  9. <form method="POST" action="go.asp">
  10.  
  11. <select size="1" name="A">
  12. <option>Select</option>
  13. <option value="POSITIVE">POSITIVE</option>
  14. <option value="NEGATIVE">NEGATIVE</option>
  15. </select>
  16.  
  17. <select size="1" name="B">
  18. <option>Select</option>
  19. <option value="0">Open</option>
  20. <option value="1">Close</option>
  21. </select>
  22.  
  23. <input type="submit" value="GO" name="B1">
  24.  
  25. </form>
  26. </body>
  27.  
  28. </html>
  29.  
If select value positive or negative in the select "A", in the select "B" required value 1, would say "Close".

If select value 2 would say "Open" in the select "B" stop the form, its possible?

Can you help me ?
Jun 6 '08 #1
7 1398
gits
5,390 Expert Mod 4TB
hi ...

i'm a little bit confused ... could you try to explain it a bit better? what should happen when you select an option in the first select-box and what should happen in case of a selection in the second one? i cannot see any value="2"?

kind regards
Jun 6 '08 #2
hi ...

i'm a little bit confused ... could you try to explain it a bit better? what should happen when you select an option in the first select-box and what should happen in case of a selection in the second one? i cannot see any value="2"?

kind regards
Sorry Gits... I wrong...

If select value positive or negative in the select "A", in the select "B" required value 1, would say "Close".

If select value 0 would say "Open" in the select "B" stop the form.

For example:

Select A ===> POSITIVE or NEGATIVE value
Select B ===> CLOSE ( value=1 ) ===> it's right

Select A ===> POSITIVE or NEGATIVE
Select B ===> OPEN ( value = 0 ) ===> it's wrong and the stop the form


You understand?
Jun 6 '08 #3
gits
5,390 Expert Mod 4TB
so the select A is irrelevant and you just need to check the selected value of select-node B ... :) check it when clicking the submit-button or onsubmit of the form

kind regards
Jun 7 '08 #4
so the select A is irrelevant and you just need to check the selected value of select-node B ... :) check it when clicking the submit-button or onsubmit of the form

kind regards

I do not understand.... :(
Jun 7 '08 #5
gits
5,390 Expert Mod 4TB
as you see ... the only thing that has to be checked is the value of select-node B ... since you said that pos or! neg could have been selected in A in any case, while the form shouldn't be submitted when node B has a value of 0. just give your node an ID and call a function onsubmit of the form ... here is an example:

Expand|Select|Wrap|Line Numbers
  1. function chk_form() {
  2.     var n = document.getElementById('my_id_for_B');
  3.  
  4.     return (n.value == 1);
  5. }
and in you html code you should have:

[HTML]<form method="POST" action="go.asp" onsubmit="return chk_form();">
[/HTML]
and even the ID:

[HTML]<select size="1" id="my_id_for_B" name="B">
[/HTML]
kind regards
Jun 8 '08 #6
Many thanks...
kind regards
Jun 9 '08 #7
gits
5,390 Expert Mod 4TB
no problem ;) ... post back to the forum anytime you have more questions ...

kind regards
Jun 9 '08 #8

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

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
8
by: Sue | last post by:
In this code why is it that when I press the SUBMIT button the focus only goes back to the Numeric field. What do I need to do to correct this problem? Sue <html>
2
by: Cliff R. | last post by:
Hello, I have a form that has a few required fields and also an "agree to terms" checkbox that must be required. I have used Javascripts for both functions individually, but I need a little help...
5
by: RobG | last post by:
I am trying to get users to fill in a form on a web page, then click a button to send an e-mail. I am using JavaScript to get the fields from the form, then run a mailto command to put the...
9
by: Good Man | last post by:
Hi This is sort of a weird question, perhaps a bit off-topic... I am on the 'edit' screen of a web form, and I have a bunch of variables coming from a database that need to be placed into the...
3
by: dshan | last post by:
Hi all, I can't find an answer to my quesiton anywhere. Given a drop-down list with USA states and other text fields I pass this information for further processing via PHP. If any of the...
5
by: Olly | last post by:
Hello Group: I'd be grateful to anyone who can help me with Javascript form. :-) I want users to submit a web form, but to stop the form submission if any of my text fields contain specific...
37
by: viki1967 | last post by:
Hi all. I have this simple form. I need if checkbox C_1 is selected: 1) field name="n_1" is required and accept only numbers; 2) field name="n_2" is required and accept only numbers; I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.