www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 10-31-2007, 09:03 PM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    Show HTML

    I am using this code to show text when a radio button is clicked.

    How can I make it show html instead of the text?

    HTML Code:
    <script type=text/javascript> 
    <!-- 
    var txt ='Please list the date and location of the event below.' 
    
    function showT(r){ 
    var rads = document.getElementsByName(r.name) 
    if(rads[0].checked){ 
    document.getElementById('RadioText').innerHTML=txt 
    document.getElementById('RadioText').style.display="block" 
    } 
    else{ 
    document.getElementById('RadioText').innerHTML="" // optional 
    document.getElementById('RadioText').style.display="none" 
    } 
    } 
    //--> 
    </script>
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #2  
    Old 10-31-2007, 11:26 PM
    Kravvitz Kravvitz is offline
    CSS & JS/DOM Adept
     
    Join Date: Jul 2005
    Location: USA
    Posts: 3,913
    Just put HTML in the "txt" string.
    __________________
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

    Check out my blog.
    Reply With Quote
      #3  
    Old 11-01-2007, 07:04 AM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    I did this and I had some it gave me an error. It said object expected. I think that was because of the syntax.

    SYNTAX:
    var txt ='Please list the date and location of the event below.
    <tr>
    <td colspan="2">Event Date:
    <input name="eventdate" type="text" id="eventdate" size="15" maxlength="150" class="form" onFocus="this.className = 'focused'" onBlur="this.className = 'blured'"/>
    Event Location: <span class="alternate"><font size="3">
    <input name="eventlocation" type="text" id="eventlocation" class="form" onfocus="this.className = 'focused'" onblur="this.className = 'blured'"/>
    </font></span> </td>
    </tr>'
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #4  
    Old 11-01-2007, 07:56 AM
    Kravvitz Kravvitz is offline
    CSS & JS/DOM Adept
     
    Join Date: Jul 2005
    Location: USA
    Posts: 3,913
    The innerHTML property of <table>s is readonly in some browsers.

    (unescaped) Newlines aren't allowed in JS strings.
    __________________
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

    Check out my blog.
    Reply With Quote
      #5  
    Old 11-01-2007, 08:11 AM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    This is my code I am still getting errors:

    <script type=text/javascript>
    <!--
    var txt ="Please list the date and location of the event below.\n\n"+
    "<tr><td colspan="2">Event Date:\n\n"+
    "<input name="eventdate" type="text" id="eventdate" size="15" maxlength="150" class="form" onFocus="this.className = 'focused'" onBlur="this.className = 'blured'"/>\n\n"+
    "Event Location: <span class="alternate"><font size="3">\n\n"+
    "<input name="eventlocation" type="text" id="eventlocation" class="form" onfocus="this.className = 'focused'" onblur="this.className = 'blured'"/>\n\n"+
    "</font></span></td></tr>";

    function showT(r){
    var rads = document.getElementsByName(r.name)
    if(rads[0].checked){
    document.getElementById('RadioText').innerHTML=txt
    document.getElementById('RadioText').style.display="block"
    }
    else{
    document.getElementById('RadioText').innerHTML="" // optional
    document.getElementById('RadioText').style.display="none"
    }
    }
    //-->
    </script>
    <input name="m_support" type="radio" value="Help with the test account" onclick="showT(this)"/>
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #6  
    Old 11-01-2007, 09:01 AM
    Kravvitz Kravvitz is offline
    CSS & JS/DOM Adept
     
    Join Date: Jul 2005
    Location: USA
    Posts: 3,913
    What errors exactly?

    Did the forum system add new lines to your code? You've got two newlines in that string that don't belong there.
    __________________
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions

    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

    Check out my blog.
    Reply With Quote
      #7  
    Old 11-01-2007, 09:35 AM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    when I click on the radio button that is suppose to show that code, I get an error in the bottom left corner if IE. When i click on it it says object expected
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #8  
    Old 11-02-2007, 11:00 AM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    any clue why this is wih the code listed?
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #9  
    Old 11-02-2007, 11:24 AM
    samliew samliew is offline
    JavaScript Hobbyist
     
    Join Date: Aug 2005
    Location: Singapore
    Posts: 155
    Code:
    <script type=text/javascript>
    <!--
    var txt = "Please list the date and location of the event below.\n\n";
    txt += "<tr><td colspan=\"2\">Event Date:\n\n";
    txt += "<input name=\"eventdate\" type=\"text\" id=\"eventdate\" size=\"15\" maxlength=\"150\" class=\"form\" onFocus=\"this.className='focused'\" onBlur=\"this.className='blured'\" />\n\n";
    txt += "Event Location: <span class=\"alternate\"><font size=\"3\">\n\n";
    txt += "<input name=\"eventlocation\" type=\"text\" id=\"eventlocation\" class=\"form\" onfocus=\"this.className='focused'\" onblur=\"this.className='blured'\" />\n\n";
    txt += "</font></span></td></tr>";
    
    function showT(r){
    	if(r.checked){
    		document.getElementById('RadioText').innerHTML=txt;
    		document.getElementById('RadioText').style.display="block";
    	}
    	else{
    		document.getElementById('RadioText').innerHTML=""; // optional
    		document.getElementById('RadioText').style.display="none";
    	}
    }
    //-->
    </script>
    <input name="m_support" type="radio" value="Help with the test account" onclick="showT(this);" />
    <span id="RadioText"></span>
    1) Didn't escape double quotes in string.
    2) Passed an element using showT(this), but still tried to get the element name, wrongly. Could just use it directly.
    Reply With Quote
      #10  
    Old 11-02-2007, 11:55 AM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    If you goto http://photoweb.esctonline.com/pwform.php

    Click on the radio buttion "an even you were at".

    How can I fix that so the Event Date is on the same line as the textbox associated with it?

    How can I make it so the radio button drops down to the "an event you were at"

    Thanks!
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #11  
    Old 11-02-2007, 12:42 PM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    This is what I am looking for
    -------------------------------------------------------------
    Radio Buttons to stay right here on top at all times
    -------------------------------------------------------------


    -------------------------------------------------------------
    Eachtime I change the radio button, I want the text to show here
    I will add directions for each radio button over time
    -------------------------------------------------------------
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #12  
    Old 11-02-2007, 02:15 PM
    JMRKER JMRKER is offline
    Registered User
     
    Join Date: Dec 2005
    Location: FL
    Posts: 4,261
    Lightbulb Consider this:

    Can you use or modify this to your needs:
    PHP Code:
    <html>
    <
    head>
    <
    title>RB Tabs</title>
    <
    style type="text/CSS">
    div.RBtnTab { display:none; height:100px; width:200px; background-color:yellow}
    </
    style>
    <
    script type="text/javascript">
    // getElementByClass function from http://www.webmasterworld.com/forum91/1729.htm
    //Create an array
      
    var allPageTags = new Array();

      function
    doSomethingWithClasses(theClass) {
    //Populate the array with all the page tags
        
    var allPageTags=document.getElementsByTagName("*");
    //Cycle through the tags using a for loop
        
    for (var i=0; i<allPageTags.length; i++) {
    //Pick out the tags with our class name
          
    if (allPageTags[i].className==theClass) {
    //Manipulate this in whatever way you want
            
    allPageTags[i].style.display='none';
          }
        }
      }

    function
    Show(ids) {
      
    doSomethingWithClasses('RBtnTab');

      var
    obj = document.getElementById(ids);
      if (
    obj.style.display != 'block') { obj.style.display = 'block'; }
                                   else {
    obj.style.display = 'none'; }
    }
    </script>
    </head>
    <body>

    <label for="lDIV1">
    <input id="lDIV1" type="radio" name='rbtab' value='DIV1' onClick="Show('DIV1')">Event Info</label>
    <label for="lDIV2">
    <input id="lDIV2" type="radio" name='rbtab' value='DIV2' onClick="Show('DIV2')">Plan Event</label>
    <label for="lDIV3">
    <input id="lDIV3" type="radio" name='rbtab' value='DIV3' onClick="Show('DIV3')">Contact Us</label>
    <div id='Content' style="display:block"><br />
    <div id='DIV1' class="RBtnTab">Event Information</div>
    <div id='DIV2' class="RBtnTab">Plan Event Information</div>
    <div id='DIV3' class="RBtnTab">Contact us at: xxx</div>
    </div>
    </body>
    </html>
    Good luck!
    Reply With Quote
      #13  
    Old 11-02-2007, 04:49 PM
    comptech520 comptech520 is offline
    FOH Audio Engineer
     
    Join Date: Apr 2005
    Location: Behind my DiGiCo SD7 Console
    Posts: 818
    I tried this:

    <div id='DIV1' class="RBtnTab"><tr><td colspan="2">Event Date: <input name="eventdate" type="text" id="eventdate" size="15" maxlength="150" class="form" onFocus="this.className = 'focused'" onBlur="this.className = 'blured'"/>Event Location: <span class="alternate"><font size="3"><input name="eventlocation" type="text" id="eventlocation" class="form" onfocus="this.className = 'focused'" onblur="this.className = 'blured'"/></font></span> </td></tr></div>

    And it didn't work.

    How can I make it so I hit the first radio button and have that display?
    __________________
    Registered Linux User: #463250
    -----------------
    HELPFUL LINKS
    PHP - http://www.php.net
    Website Color Schemer - http://www.colorschemer.com/online.html
    Reply With Quote
      #14  
    Old 11-02-2007, 04:56 PM
    JMRKER JMRKER is offline
    Registered User
     
    Join Date: Dec 2005
    Location: FL
    Posts: 4,261
    I'm not sure you can put a table row within a <div> area.
    Possibly reverse the order of the nesting.

    Also, would be a lot easier to view the code if you use the 'php' or 'code' tags of the forum.
    See examples of post #9 and #12 to see effects.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:35 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.