11-08-2005, 09:26 PM
|
#1 (permalink)
|
|
Guest
|
javascript problem
i m using java scroipt in my page. now i have one problem in that.
in that i have two simple buttons eg button1 and button2. on both i need to triger diff fuction respectively fun1 and fun2 . now fun1 fires while pessing button1 . but while pressing button2 , fun2 doesnt.
if i give in button2 to triger fun1 it runs ..
how can it be? any solution ?
|
|
|
|
|
Advertisements. Register and be a member of the community to get rid of them.
|
|
Advertisement
|
|
11-08-2005, 09:44 PM
|
#2 (permalink)
|
|
Version 2.0
Join Date: Jan 2004
Location: Mumbai
Posts: 977
|
please paste the code here so that we can understand it...
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
|
|
|
12-08-2005, 12:24 PM
|
#3 (permalink)
|
|
Human Spambot
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
|
There seems to be some problem in your fun2. As Deep said, post the code.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
|
|
|
12-08-2005, 12:27 PM
|
#4 (permalink)
|
|
Version 2.0
Join Date: Jan 2004
Location: Mumbai
Posts: 977
|
actually from looking at the description it looks like that he has mentioned name of function fun1 in button 2 (he should have mentioned fun2 function there)
but lets see the code
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
|
|
|
12-08-2005, 12:29 PM
|
#5 (permalink)
|
|
Apprentice
Join Date: Aug 2005
Location: The City Of Joy
Posts: 91
|
well its understandble the way you are describing but i think u must paste the code...that wil be a easy way to look up..
__________________
The Knight Rider
WELL YOU GONNA ALWAYS WIN
The Best Way To Contact Me Is, E-Mail Me
Get A GMail Account @ www.mbdw.s5.com
|
|
|
12-08-2005, 03:45 PM
|
#6 (permalink)
|
|
Guest
|
look the code .. in this there is two buttons B1,B2 . on B1 i fire triger function and on B2 i fire clear function . this clear fuction is not working aat all
Code:
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Fun</title>
<meta name="Microsoft Theme" content="topo 011">
</head>
<script type="text/javascript" language="javascript">
<!--
// A simple JavaScript to remove duplicate characters from a String.
//
function filter (str, pre)
{
var ctr ;
var chr ;
// alert (str) ;
var tmp = str.split (" ") ;
str = tmp.join ("") ;
// alert (str) ;
var len = str.length ;
// alert (len) ;
for (ctr = 0 ; ctr < len ; ctr++)
{
chr = str.charAt (ctr) ;
if (str.lastIndexOf (chr) != ctr)
{
// alert (chr) ;
tmp = str.split (chr) ;
str = tmp.join ("") ;
// str = str.replace (chr, "") ;
// alert (str) ;
if (typeof (pre) == "undefined" || pre == 0)
{
ctr-- ;
} else
{
// alert (str + ", " + ctr + ", " + chr + ", " + str.length) ;
str = str.substring (0, ctr) + chr + str.substring (ctr, str.length) ;
// alert (str) ;
}
len= str.length ;
}
}
//alert(str);
l = str.length;
// alert(l);
l= l%5;
// alert(l);
//alert(ss)
}
function triger()
{
if(document.forms[0].T1.value=="" || document.forms[0].T2.value == "")
{
alert("Enter both fields");
return;
}
var str;
str = document.forms[0].T1.value+document.forms[0].T2.value;
filter(str);
}
function clear()
{
alert("aAa");
document.forms[0].t1.value="";
document.forms[0].t2.value="";
document.forms[1].t1.value="";
}
//-->
</script>
<body>
</p>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse">
<tr>
<td width="150" align="center"></td>
<td align="right">
<!--webbot bot="Navigation" s-type="banner" s-rendering="graphics" S-Orientation B-Include-Home B-Include-Up U-Page S-
Target --></td>
</tr>
<tr>
<td width="100%" colspan="2" valign="top">
<!--webbot bot="Navigation" S-Type="sequence" S-Orientation="horizontal" S-Rendering="graphics" B-Include-Home="TRUE" B-
Include-Up="FALSE" U-Page="sid:1009" --></td>
</tr>
<tr>
<td width="150" align="center"></td>
<td>
This is a simple Fun game which is variant of well known
FLAMES . in that you enter your name and name of anyone and click to find
can you marry or you are enemy ..</p>
</td>
</tr>
<tr>
<td width="150" align="center"></td>
<td></td>
</tr>
<tr>
<td width="150" align="center"></td>
<td>
<form action="--WEBBOT-SELF--" method="POST" onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit >
<!--webbot bot="SaveResults" u-file="_private/form_results.csv" s-format="TEXT/CSV" s-label-fields="TRUE" startspan --
><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0">Your Name
:
<input type="text" name="T1" size="20"></p>
Your Partner's Name : <input type="text" name="T2" size="20"></p>
[color=darkred]<input type="button" value="Enter" name="B1" ONCLICK= "triger()"
>&[/color]nbsp;
[color=red]<input type="button" value="clear" name="B2" ONCLICK= "clear()"></[/color]p>
</form>
<form method="POST" action="--WEBBOT-SELF--" onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-
onSubmit>
See Your Result here : <input type="text" name="T1" size="20"></p>
</form>
<p align="center"></p>
<!--webbot bot="Navigation" s-orientation="horizontal" s-rendering="html" s-bar="Bars" s-btn-nml="<A
HREF="#URL#" TARGET="#TARGET#" STYLE="text-decoration: none;">#LABEL#</A>" s-btn-
sel="#LABEL#" s-btn-sep="&nbsp;|&nbsp;" s-type="siblings" b-include-home="TRUE" b-include-up="FALSE" --></p>
</td>
</tr>
</table></center>
</div>
</body>
</html>
|
|
|
|
12-08-2005, 06:19 PM
|
#7 (permalink)
|
|
Version 2.0
Join Date: Jan 2004
Location: Mumbai
Posts: 977
|
hmm function name clear seems to be reserved name..rename the function to something else..it will work
btw why are you using function to clear the fields? just use type="reset" it will do the job
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
|
|
|
12-08-2005, 07:43 PM
|
#8 (permalink)
|
|
Broken In
Join Date: Aug 2005
Location: The Moon
Posts: 110
|
Exactly!
For clearing the fields, u can simply use type="reset" and the job will be done my friend!!
No need to get into so much hassels atall!!
__________________
The Wind Blows, The Flowers Bloom,
Open Your Eyes, Here Comes The Moon!
|
|
|
12-08-2005, 08:12 PM
|
#9 (permalink)
|
|
Wise Old Owl
Join Date: May 2005
Location: Chennai, India, Asia, the Earth, the Solar system, the Milky Way, the Local group, this Universe.
Posts: 1,171
|
But then, why didn't it work? I just wanna learn .
__________________
http://myxp.blogspot.com
-----------------------
Winchester 3200+ @2,500MHz
LeadTek 7900GT VOLT MODDED @ 680 core, 1800 mem
2x1GB Transcend DDR400 @ DDR454 2.5,3,3,5,1T
|
|
|
12-08-2005, 08:13 PM
|
#10 (permalink)
|
|
Version 2.0
Join Date: Jan 2004
Location: Mumbai
Posts: 977
|
I have already mentioned the reason...
clear is reserved name so cant be used for function...
if you rename it to clear1 then it will work
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
|
|
|
12-08-2005, 08:14 PM
|
#11 (permalink)
|
|
Wise Old Owl
Join Date: May 2005
Location: Chennai, India, Asia, the Earth, the Solar system, the Milky Way, the Local group, this Universe.
Posts: 1,171
|
Ah, k thx.
__________________
http://myxp.blogspot.com
-----------------------
Winchester 3200+ @2,500MHz
LeadTek 7900GT VOLT MODDED @ 680 core, 1800 mem
2x1GB Transcend DDR400 @ DDR454 2.5,3,3,5,1T
|
|
|
12-08-2005, 09:10 PM
|
#12 (permalink)
|
|
Guest
|
ok thx i will try .. and you knw in this i have three text box and they are in diff forms so reset button of that form will not reset textbox of other form na so i want to use. .. and you are also rite i can put all this is in one form and use reset . . but after i was some lazy to change it so went for function. .
|
|
|
|
12-08-2005, 09:11 PM
|
#13 (permalink)
|
|
Guest
|
working yar .. thanx deep
|
|
|
|
12-08-2005, 09:12 PM
|
#14 (permalink)
|
|
Version 2.0
Join Date: Jan 2004
Location: Mumbai
Posts: 977
|
lol get everything in one form and then do it..thats my suggestion
Edit: oh great to hear that it worked for u
good luck
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
|
|
|
13-08-2005, 01:42 AM
|
#15 (permalink)
|
|
Human Spambot
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
|
Deep man, you are pretty fast  By the time I came back, you've already solved the problem!!
But somehow I am more comfortable with PHP then Javascript. Of course, they both compliment each other, one being used mainly for server side scripting and the other mainly for client side scripting.
But I don't know why I am more comfortable with PHP. May be because PHP code can't be seen just by viewing page source in browser
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
|
|
|
13-08-2005, 01:45 AM
|
#16 (permalink)
|
|
Version 2.0
Join Date: Jan 2004
Location: Mumbai
Posts: 977
|
Quote:
|
Originally Posted by tuxfan
Deep man, you are pretty fast  By the time I came back, you've already solved the problem!!
But somehow I am more comfortable with PHP then Javascript. Of course, they both compliment each other, one being used mainly for server side scripting and the other mainly for client side scripting.
But I don't know why I am more comfortable with PHP. May be because PHP code can't be seen just by viewing page source in browser 
|
actually I too prefer PHP and I am not at all good at javascript but you know sometimes javascript is very useful specially for some quick validations...like blank fields etc...
takes less time but ofcourse i would do server side validations as well along with javascript
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
|
|
|
13-08-2005, 01:50 AM
|
#17 (permalink)
|
|
Human Spambot
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
|
I agree
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
|
|
|
17-08-2005, 04:40 PM
|
#18 (permalink)
|
|
Guest
|
hey this all working fine till now . now i get other error .. in this as i gave code i have writen like document.forms[0].t1.value="" so when i execute on browser from net i get error like error at some line error : document.forms.0.T1.value is null or not an object !!!
when i saw source from view source it is like original means forms[0] , while in error brackets are not there !!!
now what to do?
|
|
|
|
17-08-2005, 06:53 PM
|
#19 (permalink)
|
|
Version 2.0
Join Date: Jan 2004
Location: Mumbai
Posts: 977
|
yup it will show error coz you have given wrong variable names in clear function...
Code:
document.forms[0].t1.value="";
document.forms[0].t2.value="";
document.forms[1].t1.value="";
your form field names are T1 AND T2.
variable names are case sensitive
Deep
__________________
- Deep Ganatra -
www.whoisdeep.com
www.twitter.com/DeepXP/
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|