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
sasha85Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SvenConnect With a Mentor Tech 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
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
 
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
All Courses

From novice to tech pro — start learning today.