473,670 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript Subroutine Problem

4 New Member
The following line of script code works correctly:

Expand|Select|Wrap|Line Numbers
  1. w('<input type=radio name=rad onclick="myImg.src=\'../Audio Streaming/'+myPhoto+'\';">');
When onclick is executed, the variable "myPhoto" is correctly loaded as the source for "myImg" which is then displayed.

I need to accomplish several tasks when "onclick" is executed and I am trying to setup a subroutine "mySub" to perform the various tasks. I created a subroutine as follows, located in the <body> of the html routine.

Expand|Select|Wrap|Line Numbers
  1. <sub mySub(x)
  2. {
  3. myImg.src=\'../Audio Streaming/'+x);
  4. }
  5.  
I replaced the above line of code with :

Expand|Select|Wrap|Line Numbers
  1. w('<input type=radio name=rad onclick="mySub(myPhoto)">');
to pass the parameter "myPhoto" to the subroutine, but I keep getting the error message "Object Expected".

Can anyone tell me what I am doing wrong?

Thanks - Patrick Russell
Oct 26 '08 #1
2 1608
zaphod42
55 New Member
I can't see where myPhoto is defined in the scope of what you're doing....do you have any more javascript on the page?
Oct 26 '08 #2
PVACC
4 New Member
I can't see where myPhoto is defined in the scope of what you're doing....do you have any more javascript on the page?
Yes I do have other javascript. The major portion is as follows:

Expand|Select|Wrap|Line Numbers
  1. function w(s)
  2. {
  3.     document.writeln(s);
  4. }
  5. var previousSpeaker="", previousSeries="";                    // initialize variables to empty string
  6. for(var i=0; i<parent.audio_info.length; i++)                  // loop through all listed audios
  7. {
  8.     var sermon=parent.audio_info[i];                        // get next audio as an array of 5 strings
  9.     var mySwf=sermon[0];    // Streaming Audio "swf" file
  10.     var mySpeaker=sermon[1];    // Speaker's Name
  11.     var myPhoto=sermon[2];     // Speaker's "jpg" photo
  12.     var mySeries=sermon[3];     // Sermon Series Title
  13.     var myTitle=sermon[4];    // Sermon Title
  14.  
  15.     if(mySpeaker!=previousSpeaker || mySeries!=previousSeries)  // new speaker or series?
  16.     {
  17.         w('<br><span style="font-family: Swis721 Blk BT">');
  18.         w('<font size="4" color="#333399">');
  19.         w(mySpeaker);
  20.         w('</font></span>');
  21.         w(' : '+mySeries);
  22.         w('<br>');
  23.     }
  24.     w('<input type=radio name=rad onclick="mySub(myPhoto)">');
  25.     w(myTitle);
  26.     w('<br>');
  27.     previousSpeaker=mySpeaker; 
  28.     previousSeries=mySeries;
  29. }
Code continues ... Basically, the user selects a radio button from a list, from which the correct sermon tiltle and audio flash file are extracted and used.
Oct 27 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5060
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when they press "Cancel" they call another ASPX function. My code now is: System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf) System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to...
2
1546
by: asadikhan | last post by:
Hi, I have a timer in javascript on my ASP.NET page. When the time expires (a point in my javascript code) I want to call a subroutine in my ASP.NET page. But I can't seem to figure out how to do this. My subroutine is actually a function I call as a result of a button click. But if the user doesn't click the button in the allotted time, I want to go ahead and call the function anyways. Any idea how I can do this?
5
1627
by: Dave | last post by:
I have an app with several web forms. Code for each of the forms contains a subroutine I wrote that performs the Javascript function "alert". Thus: Private Sub DisplayAlert(ByVal msg As String) Dim sKey As String = "s" Dim alertScript As String = "<script language=JavaScript runat=server> " alertScript &= "alert('" & msg & "');" alertScript &= "</script>" RegisterClientScriptBlock(sKey, alertScript) End Sub
2
1434
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! **************************************************************************************************** Original Question: -------------------- Has anyone called a COBOL subroutine using COBOL CALL from a COBOL/DB2
7
5202
by: shil | last post by:
Hi all, Can any one direct me in how to use javascript confirm() function when a condition is met from codebehind. I don't want to attach this to a button. When I submit the page, I want to check some business rules, and based on the response from the database, if the response is Yes, I need to display a confirmation alert to user. When the user clicks ok, then I should take an action, if not, exit out of the subroutine. Below is the...
2
1672
by: victor.buga | last post by:
Hi, Could somebody please guide me how to retrieve the subroutine that's on the server, and using javascript tell the server to invoke that subroutine. Everything is in the same ".asp" page. ============================================================================= <%
10
1879
by: nasau | last post by:
Perl, I have a main program which calls two subroutines (depending upon the report names).In the subroutine I am printing the data from CSV file using the format variable, Format_top prints the report header and STDOUT prints the report data. Both these subroutine runs fine individually, independent of each other. Now I have included both these subroutine in my main program and I call these subroutine depending upon the name of the report. Here...
4
2601
by: otterbyte | last post by:
Hi, I have a bit of code which is confusing me to no end. Here are the basics: 1) The class module is being used in the module of a form. 2) There is an instance of the object declared at the form level, and instantiated in the Load event of the form. This instance holds the "current" values (based on data in a table), and it's called ordCurrent.
4
1840
by: MartinRinehart | last post by:
I've written a short article explaining closures in JavaScript. It's at: http://www.martinrinehart.com/articles/javascript-closures.html I think I've understood. I look forward to your constructive critique.
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5686
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4213
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2802
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.