Solved

how can asp call js function?

Posted on 2007-11-15
7
403 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 11

Accepted Solution

by:
Sven earned 350 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
<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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

772 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

9 Experts available now in Live!

Get 1:1 Help Now