y is it not workin

T

thejes john

could u plz help me in solving this problem.y the following is not
working


<script language="javascript">
function btnClear()
{
document.Loc_Emp.T1.value="";
document.Loc_Emp.T2.value="";
document.Loc_Emp.T3.Value="";
}
function btnSearch()
{

if(document.Loc_Emp.T1.value==" " &&
document.Loc_Emp.T2.value==" " && document.Loc_Emp.T3.value==" ")
{
alert("Please enter any one value");
}
else
{
document.Loc_Emp.submit();}
}

</script>
 
J

Jonas Raoni

thejes said:
function btnSearch() {
if(document.Loc_Emp.T1.value==" " && document.Loc_Emp.T2.value==" " && document.Loc_Emp.T3.value==" "){
alert("Please enter any one value");
}
else {
document.Loc_Emp.submit();
}
}

You didn't said what isn't working, the error, etc. So I guess your
problem is just in the above piece of code, where you should replace " "
by "" =b

Anyway, this approach is bad, you must have a good reason to call
"form.submit" inside JavaScript.

ps: Don't use short words on a global newsgroup, I'm not american for
example ;]
 
T

Thomas 'PointedEars' Lahn

thejes said:
could u plz help me in solving this problem.

In case this is a question (I do not see a question mark, though):
Who is "u", and is he/she subscribed to this newsgroup?
y the following is not working
[...]
alert("Please enter any one value");
^
The "y" is working fine here. Your problem must be elsewhere.


SCNR

PointedEars
 
L

Lasse Reichstein Nielsen

thejes john said:
could u plz help me in solving this problem.y the following is not
working

To fix a problem, we must be able to
1) reproduce,
2) recognize, and
3) repair it.

For 1) we need to have the entire page that fails (I prefer a link to the
live page), or better yet, a small self-contained example that exhibits
the problem. For 2) you must say what the problem is, and "not working"
is not it. How does what happens differ from what you wanted?
For 3) we must also know what you did want to happen.

Without that, the best we can do is guess.
<script language="javascript">
function btnClear()
{
document.Loc_Emp.T1.value="";

The recommended way to access a form control is through the forms
collection, i.e.,
document.forms['Loc_Emp'].elements['T1'].value = "";
That's unlikely to be a problem though.
document.Loc_Emp.T2.value="";
document.Loc_Emp.T3.Value="";
}
function btnSearch()
{

if(document.Loc_Emp.T1.value==" " &&
document.Loc_Emp.T2.value==" " && document.Loc_Emp.T3.value==" ")

This looks like an attempt at checking that something has been entered
into at least one of three form controls. You probably mean to compare
to "" (the empty string, and the initial value of a text form control if
no value was provided) and not " ", the string containing a single space.
{
alert("Please enter any one value");
}
else
{
document.Loc_Emp.submit();}
}

This submission is better performed by the form itself. If you return
false from the error branch, after the alert, you can call the test
function as:

<form action="..." onsubmit="return btnSearch(this);">

(I pass the form as a parameter, making it even easier to access the
controls from inside the function).


Regards
/L
 
T

thejes john

thank you so much for the detailed explanation.this is the first time
im sending a query in net.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top