|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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. |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
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 |
|
#9
|
|||
|
|||
|
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>
2) Passed an element using showT(this), but still tried to get the element name, wrongly. Could just use it directly. |
|
#10
|
|||
|
|||
|
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 |
|
#11
|
|||
|
|||
|
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 |
|
#12
|
|||
|
|||
|
Can you use or modify this to your needs:
PHP Code:
|
|
#13
|
|||
|
|||
|
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 |
|
#14
|
|||
|
|||
|
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. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|