Re: y is it not workin
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: y is it not workin

From: Lasse Reichstein Nielsen <lrn@hotpop.com>
Date: Tue Feb 28 2006 - 17:59:01 CET

"thejes john" <thejesjohn@yahoo.co.in> writes:

> 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

-- 
Lasse Reichstein Nielsen  -  lrn@hotpop.com
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'
Received on Mon May 1 03:41:17 2006