Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 445
  • Last Modified:

how can asp call js function?

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
sasha85
Asked:
sasha85
1 Solution
 
imitchieCommented:
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
 
SvenTech Lead Web-DevelopmentCommented:
You can only transmit data with reloading page and using querystring or by posting the data to the server (AJAX).
0
 
sasha85Author Commented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
SvenTech Lead Web-DevelopmentCommented:
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
 
sasha85Author Commented:
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
 
SvenTech Lead Web-DevelopmentCommented:
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
 
pavaneeshkumarCommented:
<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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now