473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Javascript Subroutine Problem

4
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 1601
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
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
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...
2
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...
5
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)...
2
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! ...
7
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...
2
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
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...
4
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.