Understanding the "onclick" option

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PVACC
    New Member
    • Oct 2008
    • 4

    Understanding the "onclick" option

    I have a line of code thus:

    w3('<input type=radio name=rad onclick="parent .mySub('+i+')"> ');

    The function w3() writes the code in an iframe. I need to set a variable "start" to the value "1" when a radio button is selected but BEFORE executing "parent.mySub() ". Can anyone help me with the required code?

    Thanks
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    This is a JavaScript question so I've moved it there for you.

    -Moderator.

    Which radio button? The one that's added? Can you post the code for w3().

    Comment

    • PVACC
      New Member
      • Oct 2008
      • 4

      #3
      Understanding the javascript &quot;onclick&q uot; option

      My module automatically writes this line of code to an iframe, resulting in a complete list of selectable items, each of which has a radio button. The w3() code simply looks like this ...

      Code:
      	function w3(s)	// Writes to "Listings" iframe
      	{
      		Listings.document.writeln(s);
      	}
      The mySub() code called by "onclick" looks like this ...

      Code:
      function mySub(n)
      {
      
      	sermon=parent.audio_info[n];
      	Swf=sermon[0];
      	Speaker=sermon[1];
      	Photo=sermon[2];
      	Series=sermon[3];
      	Title=sermon[4];
      	SpeakerImg.src='../Audio Streaming/'+Photo;
      	DisplayAudioControl();		
      }
      
      function DisplayAudioControl()	// Output to "Audioframe"
      {
      	AudioFrame.document.close();	// Clear contents of iframe
      	w2('<font size="4" face="Corbel,Helvetica">');
      	if(start>0)
      	{
      		w2('<a href="http://bytes.com/answers/Audio_files/'+Title+'.mp3">');
      		w2('<p align=center>');
      		w2(Title);
      		w2('</a>');	
      	}
      	w2('<br><br>');
      etc ...

      When any radio button from the list is selected, I want to set the variable "start" to the value "1" so that when the function "mySub() and DisplayAudioCon trol() are called, the "if statement" directs accordingly. I was of the understanding that the "onclick" option could have several parts to it separated by semicolons, but these appear not to work. Can the "onclick" option be modified to include setting the variable start to the value 1?

      If you want to view my website, go to "www.pvacc. com" and then select "Audio Archives". The iframe "Listings" is generated automatically by the one line of code within a loop.

      Thanks,
      Last edited by acoder; Dec 4 '08, 08:17 AM. Reason: Added [code] tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You could use parent.start=1.

        Comment

        Working...