473,385 Members | 1,798 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,385 software developers and data experts.

JavaScript funtion not run

Hello,
<%@ Language=VBScript %>
<%
Response.Write "<INPUT type=""button"" value=""Button"" id=button1
name=button1"">"
Response.Write "<INPUT type=""button"" value=""Button"" id=button2
name=button2"">"
%>
<Script language="VBScript">
function button1_onclick()
document.Write "ab"
end function
</script>
<Script language=JavaScript>
function button2_onclick()
{
document.write("ac");
}
</script>
When clicks button1,shows "ab".But clicks button2 cannot show "ac".How can
run function button2_onclick()?
Thank you

Jul 19 '05 #1
4 1284
Dear Jack..

I can't speak English...So very simply...

<script language="javascript">
<!--
function btnClick()
{
document.all.gogo.innerHTML = "ac";
}
//-->
</script>

<input type="button" value="Click" name="btnTest" onClick="btnClick();">
<p id="gogo"></p>

It's not recommend what use VBScript and Javascript in one ASP page because
Two ScriptEngine reloaded in memory

Jul 19 '05 #2
VBScript allows events to be automagically linked to HTML elements via a
naming convention (same as in VB).
However, JavaScript requires that events are assigned either in the HTML
itself or dynamically at runtime.

1. Static
<INPUT ....... onclick="myfunction();" .... value="Test" />

function myfunction(){
alert('Input was clicked and has a value of ' + this.value);
}

2. Dynamic
//No requirement to specify parameters - we are in fact just assigning an
object reference.
document.getElementById('mybutton').onclick = myfunction;

function myfunction(){
alert('Input was clicked and has a value of ' + this.value);
}

NB: 'this' is a very specific JavaScript thing that refers to the object
that called the function - in actual fact it refers to the parent object of
the function - in this case it's the HTML input that the function is
assigned to.

Hope this helps.

Chris.

"Jack" <si*****************@noyahoo.co.jp> wrote in message
news:ut****************@TK2MSFTNGP10.phx.gbl...
Hello,
<%@ Language=VBScript %>
<%
Response.Write "<INPUT type=""button"" value=""Button"" id=button1
name=button1"">"
Response.Write "<INPUT type=""button"" value=""Button"" id=button2
name=button2"">"
%>
<Script language="VBScript">
function button1_onclick()
document.Write "ab"
end function
</script>
<Script language=JavaScript>
function button2_onclick()
{
document.write("ac");
}
</script>
When clicks button1,shows "ab".But clicks button2 cannot show "ac".How can
run function button2_onclick()?
Thank you
Jul 19 '05 #3
Thank you

Jul 19 '05 #4
Thank you very much

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
0
by: nic | last post by:
Hi, I need to get the equivilent of Response.Redirect (~/mypage.aspx) for a dynamic javascript function. Essentially I am writing the javascript on the non-code behind page and need to inject the...
1
by: Benny | last post by:
hello all, currently im working on an asp.net web application using c#. im able to calling a javascript funtion in the .aspx page from the .aspx.cs page method. however, now i want other way...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
6
by: Mantorok | last post by:
Hi I have a user control (ascx) and it has some javascript, however I want to use 3 instances of this control on my form - the problem is that the javascript functions are all being generated 3...
3
by: TJ | last post by:
Hi, I would like to ask something to user after user submits the form... I know I can ask user whehter they want to submit the form or not using client-script code such as onClick or onSubmit by...
5
by: Lee Xuzhang | last post by:
/* from SICP -- Exercise 4.21: ((lambda (n) ((lambda (fact) (fact fact n)) (lambda (ft k) (if (= k 1) 1 (* k (ft ft (- k 1))))))) 10) */
6
by: pronerd | last post by:
Hi, I am trying to dynamically set an event handler across frames. I have no problems setting properties across frames doing something like parent.ToolMenuFrame.location.href =...
8
by: nkoriginal | last post by:
Hi: (this is a dummy question, I know, but I tried many times and I cant) I need to insert this javascript option inside the input, I can't insert any funtion in <head> I've this two...
2
by: wolverine2512 | last post by:
Hello .Net Wizards! I would like to seek your help on how to call javascript function from code behind of VB.net. I have javascript function named Openform() and i want to execute it on page load,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.