Link to home
Start Free TrialLog in
Avatar of sasha85
sasha85

asked on

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
Avatar of imitchie
imitchie
Flag of New Zealand image

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()" />
You can only transmit data with reloading page and using querystring or by posting the data to the server (AJAX).
Avatar of sasha85
sasha85

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Sven
Sven
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sasha85

ASKER

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?
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!
<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