Solved

how can asp call js function?

Posted on 2007-11-15
7
411 Views
Last Modified: 2012-08-13
i mean with no user help...no links no actions...
<input type="button" value="Click Me!" onclick="getData()" />

just want add inside of some if a code that will call js function
0
Comment
Question by:sasha85
7 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20288139
you can still have javascript sections in asp pages, i.e.

<script language="javascript">
 function getData() {
   // js code
 }
</script>

and referenced in your html  <input type="button" value="Click Me!" onclick="getData()" />
0
 
LVL 11

Expert Comment

by:Sven
ID: 20288146
You can only transmit data with reloading page and using querystring or by posting the data to the server (AJAX).
0
 

Author Comment

by:sasha85
ID: 20288167
you mean:
if x=y then
js1...
else
js2
end if
?

do you know where i can find a good ajax\ajaxed example that i can view its code and make some changes?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Accepted Solution

by:
Sven earned 350 total points
ID: 20288176
I think I missunderstood your question ;)

As imitchie said you can use a code like the following:
<%

If x = y Then

  %>

  <script language="javascript">

  <!--

  alert('1');

  //-->

  <%

Else

  %>

  <script language="javascript">

  <!--

  alert('2');

  //-->

  <%

End If

%>

Open in new window

0
 

Author Comment

by:sasha85
ID: 20288203
what did you mean with the ajax?
somehow always when i find a nice short code of ajax on the web and i copy it to my computer
i got "ajaxed is undefined' do you know why can it be?
0
 
LVL 11

Expert Comment

by:Sven
ID: 20288222
I thought you would set data of the client javascript to asp.

If you copy Ajax-code you also need the included framework (like prototype.js). Please post another question for this with code examples!
0
 
LVL 5

Expert Comment

by:pavaneeshkumar
ID: 20288376
<input type="button" value="Click Me!" onclick="getData()" /> change this line to

<input type="button" value="Click Me!" onclick="getData();" />

see this code Snippet
<html><title>hello js</title>

<script type="text/javascript">
 

function hello()

{

	alert("Hello from button click");

}

</script>
 

<body>
 

<form>

<input type="button" value="CodingForums" onClick="hello();" />

</form>

</body>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now