on 04-07-2006 5:32 AM
Hi all,
I am trying to check the value of the checkbox( true or false) in javascript in page layout by
if (formid.checkboxid.checked == "TRUE" )..
But it is not working ? giving syntax error in JavaScript.. What is the right syntax ? Thanks in advance.
Regards,
Ananya
Hi Ananya,
Here is a sample code.
<html>
<head>
<script language=javascript>
function validate(chk1,chk2,chk3,chk4){
if (chk1.checked == 1)
alert("You have selected Red");
if (chk2.checked == 1)
alert("You have selected Orange");
if (chk3.checked == 1)
alert("You have selected Blue");
if (chk4.checked == 1)
alert("You have selected Pink");
if(chk1.checked == 0 && chk2.checked == 0 && chk3.checked == 0 && chk4.checked == 0)
{
alert("You didn't check any thing! Let me check it for you.")
chk1.checked = 1;
}
}
</script>
</head>
<body>
<form>
What's is your favourite color?
<br>
<input type=checkbox name=chk1>Red
<br>
<input type=checkbox name=chk2>Orange
<br>
<input type=checkbox name=chk3>Blue
<br>
<input type=checkbox name=chk4>Pink
<br>
<p><input type=button value="Submit" onclick="return validate(chk1,chk2,chk3,chk4);">
</form>
</body>
</html>
Hope it solves your problem.
Regards,
Maheswaran.B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Solved the problem..Thanks a lot.
Regards
Ananya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anaya,
Here is the BSP Code.
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<script language=javascript>
function validate(chk1,chk2,chk3,chk4){
if (chk1.checked == 1)
alert("You have selected Red");
if (chk2.checked == 1)
alert("You have selected Orange");
if (chk3.checked == 1)
alert("You have selected Blue");
if (chk4.checked == 1)
alert("You have selected Pink");
}
</script>
<htmlb:content design="design2003" >
<htmlb:page title="Checkbox " >
<htmlb:form>
Which is your fav. color?
<br>
<htmlb:checkbox id = "c1"
text = "Red" />
<htmlb:checkbox id = "c2"
text = "Orange" />
<htmlb:checkbox id = "c3"
text = "Blue" />
<htmlb:checkbox id = "c4"
text = "Pink" />
<br>
<input type=button value="Submit" onclick="return validate(c1,c2,c3,c4);">
</htmlb:form>
</htmlb:page>
</htmlb:content>
I hope this solves your problem.
Regards,
Maheswaran.B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anaya,
Here is the BSP Code.
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<script language=javascript>
function validate(chk1,chk2,chk3,chk4){
if (chk1.checked == 1)
alert("You have selected Red");
if (chk2.checked == 1)
alert("You have selected Orange");
if (chk3.checked == 1)
alert("You have selected Blue");
if (chk4.checked == 1)
alert("You have selected Pink");
}
</script>
<htmlb:content design="design2003" >
<htmlb:page title="Checkbox " >
<htmlb:form>
Which is your fav. color?
<br>
<htmlb:checkbox id = "c1"
text = "Red" />
<htmlb:checkbox id = "c2"
text = "Orange" />
<htmlb:checkbox id = "c3"
text = "Blue" />
<htmlb:checkbox id = "c4"
text = "Pink" />
<br>
<input type=button value="Submit" onclick="return validate(c1,c2,c3,c4);">
</htmlb:form>
</htmlb:page>
</htmlb:content>
I hope this solves your problem.
Regards,
Maheswaran.B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ananya,
Go through the link...
http://www.devx.com/tips/Tip/13204
It is very clear. Isn't it?
I am assuming that you have gone through the link...
It's not that for each and every check box you need a button to validate it...
After the user enters all fields in the form normally you have a submit button.
In the onClick of the submit button just pass all the names of the check box and check whether they are checked
or not?
Hope it helps.
Regards,
Maheswaran.B
Message was edited by: Maheswaran B
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.