Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Unhappy Dynamic Content and Styles problem...

    Alright, So I've been trying to do this ALL weekend for my online java class... and cant seem to figure it out! It's been killing me... If anyone could help me out, I would GLADLY appreciate it!!!


    Here is a shortened version of the HTML.... followed by one of the functions in javascript that im having the problem with...

    basically, when the user selects a name from a select dropdown menu, I want to change the actors names in the html to black, along with their lines... and everyone else to red.

    So far, I can properly change just their NAME to red and black correctly... but not their block quotes :confused:

    Java Code:
    <h3>PROSPERO</h3>
    <blockquote><i>Enter PROSPERO in his magic robes, and ARIEL</i></blockquote>
    <blockquote>Now does my project gather to a head:<br />
    My charms crack not; my spirits obey; and time<br />
    Goes upright with his carriage. How's the day?
    </blockquote>
    
    <h3>ARIEL</h3>
    <blockquote>On the sixth hour; at which time, my lord,<br />
    You said our work should cease.
    </blockquote>
    
    <h3>PROSPERO</h3>
    <blockquote>I did say so,<br />
    When first I raised the tempest. Say, my spirit,<br />
    How fares the king and's followers?
    </blockquote>
    
    <h3>ARIEL</h3>
    <blockquote>Confined together<br />
    In the same fashion as you gave in charge,<br />
    Just as you left them; all prisoners, sir,<br />
    In the line-grove which weather-fends your cell;<br />
    They cannot budge till your release. The king,<br />
    His brother and yours, abide all three distracted<br />
    And the remainder mourning over them,<br />
    Brimful of sorrow and dismay; but chiefly<br />
    Him that you term'd, sir, 'The good old lord Gonzalo;<br />
    His tears run down his beard, like winter's drops<br />
    From eaves of reeds. Your charm so strongly works 'em<br />
    That if you now beheld them, your affections<br />
    Would become tender.
    </blockquote>
    
    <h3>PROSPERO</h3>
    <blockquote>Dost thou think so, spirit?
    </blockquote>
    
    <h3>ARIEL</h3>
    <blockquote>Mine would, sir, were I human.
    </blockquote>
    
    <h3>PROSPERO</h3>
    <blockquote>And mine shall.<br />
    Hast thou, which art but air, a touch, a feeling<br />
    Of their afflictions, and shall not myself,<br />
    One of their kind, that relish all as sharply,<br />
    Passion as they, be kindlier moved than thou art?<br />
    Though with their high wrongs I am struck to the quick,<br />
    Yet with my nobler reason 'gaitist my fury<br />
    Do I take part: the rarer action is<br />
    In virtue than in vengeance: they being penitent,<br />
    The sole drift of my purpose doth extend<br />
    Not a frown further. Go release them, Ariel:<br />
    My charms I'll break, their senses I'll restore,<br />
    And they shall be themselves.
    </blockquote>
    
    <h3>ARIEL</h3>
    <blockquote>I'll fetch them, sir.</blockquote>
    
    <blockquote><i>Exit</i></blockquote>
    
    <h3>PROSPERO</h3>
    <blockquote>Ye elves of hills, brooks, standing lakes and groves,<br />
    And ye that on the sands with printless foot<br />
    Do chase the ebbing Neptune and do fly him<br />
    When he comes back; you demi-puppets that<br />
    By moonshine do the green sour ringlets make,<br />
    Whereof the ewe not bites, and you whose pastime<br />
    Is to make midnight mushrooms, that rejoice<br />
    To hear the solemn curfew; by whose aid,<br />
    Weak masters though ye be, I have bedimm'd<br />
    The noontide sun, call'd forth the mutinous winds,<br />
    And 'twixt the green sea and the azured vault<br />
    Set roaring war: to the dread rattling thunder<br />
    Have I given fire and rifted Jove's stout oak<br />
    With his own bolt; the strong-based promontory<br />
    Have I made shake and by the spurs pluck'd up<br />
    The pine and cedar: graves at my command<br />
    Have waked their sleepers, oped, and let 'em forth<br />
    By my so potent art. But this rough magic<br />
    I here abjure, and, when I have required<br />
    Some heavenly music, which even now I do,<br />
    To work mine end upon their senses that<br />
    This airy charm is for, I'll break my staff,<br />
    Bury it certain fathoms in the earth,<br />
    And deeper than did ever plummet sound<br />
    I'll drown my book.
    </blockquote>
    
    <blockquote><i>Solemn music</i></blockquote>
    
    <blockquote><i>Re-enter ARIEL before: then ALONSO, with a frantic gesture, attended by GONZALO; SEBASTIAN and ANTONIO in like manner, attended by ADRIAN and FRANCISCO they all enter the circle which PROSPERO had made, and there stand charmed; which PROSPERO observes.</i></blockquote>
    Java Code:
    function filterScene(e)
    {
    	var listBox = e.target || event.srcElement;
    	
    	var h3t = document.getElementsByTagName("h3");
    
    	for(var l = 0; l < h3t.length; l++)
    	{
    		if(listBox.value != h3t[l].innerHTML)
    		{
    			// Turn non-names red
    			h3t[l].style.color = "red";
    		}
    		else
    		{
    			// Turn Selected Character Black
    			h3t[l].style.color = "black";
    		}
    	}	
    }

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    You might have better luck at a JavaScript forum. (This one is for Java: a different language.)

Similar Threads

  1. Problem with getting content from site
    By dedmorozor in forum Java Applets
    Replies: 4
    Last Post: 07-16-2010, 09:15 AM
  2. problem with changes of Dynamic input width box
    By synclenovo in forum New To Java
    Replies: 1
    Last Post: 04-09-2009, 12:15 AM
  3. JTextPane Styles Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:48 PM
  4. Replies: 0
    Last Post: 02-12-2008, 05:05 PM
  5. JOptionPane - message styles
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •