Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2005, 11:21 AM
Authorized User
 
Join Date: Jul 2005
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trigger javascript using ASP

Is that possible?

 
Old September 22nd, 2005, 05:07 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

What exactly are you trying to do?

Is the javascript client or server-side?

Cheers,

Chris

 
Old September 22nd, 2005, 06:11 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii g2000!!
 offcourse you can do this
<script>
function myfun()
{
//ur code
}
</script>
<%
a=10
'asp code here
if(a=10) then
 %>
   <script>
    myfun();
   </script>
<% end if%>
hope this will help you

Cheers :)

vinod
 
Old September 22nd, 2005, 06:44 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

or even embed the whole function inside a ASP IF statement:

[code]

<% if Picco = true then %>
<script language=javascript>
function picco()
{
....
.your JS code
....

....
}

</script>

<% end if%>

HTH,

Picco

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
 
Old September 23rd, 2005, 08:22 AM
Authorized User
 
Join Date: Jul 2005
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks guys! but.... It seems some are executed and some aren't.

here's the extract:

<% If rs("mySelect1") <> "" Then %>
  <script language="javascript">
    alert('test');
    document.getElementById('mySelect1').value =
        <% =rs("mySelect1") %> ;
  </script>
<% End If %>

<select name="mySelect1" id="mySelect1">
  <option value="">---</option>
  <option value="1">1</option>
  <option value="2">2</option>
</select>

Any clue?

 
Old September 23rd, 2005, 08:23 AM
Authorized User
 
Join Date: Jul 2005
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I meant the alert box pops up but the select box won't be selected.

 
Old September 25th, 2005, 11:30 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii g2000!!

Change your code execution steps :)
i.e


<select name="mySelect1" id="mySelect1">
  <option value="">---</option>
  <option value="1">1</option>
  <option value="2">2</option>
</select>

<% If rs("mySelect1") <> "" Then %>
  <script language="javascript">
    alert('test');
    document.getElementById('mySelect1').value =
        <% =rs("mySelect1") %> ;
  </script>
<% End If %>


Note-The reason is that at the time of script executing there is no element with 'mySelect1' option ,so you need to place ur script just below to Option.
Hope this will help you

Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
trigger stored procedures from asp Kornel Classic ASP Databases 7 July 15th, 2004 10:47 PM
asp/javascript Toka1 Classic ASP Basics 4 April 26th, 2004 06:13 AM
asp within javascript? vivalet Javascript How-To 2 November 14th, 2003 04:17 PM
asp and javascript. face Classic ASP Databases 1 September 22nd, 2003 11:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.