Reducing InnerHTML > Function Set
Apr 29, 2002
In my current folio site I have used IDed spans with the innerHTML command to alter descriptions of folio items.
I have 3 text strings that are all changed: Title, Dimensions and Description.
The spans are called worktitle, dimensions and about, respectively.
Each button in the section sub-menu has the following set of commands (with varying texts):
onclick="worktitle.innerHTML='title blah blah' dimensions.innerHTML='dimensions blah blah' about.innerHTML='description blah blah'"
I would like to be able to use functions instead and turn the set into something like:
onclick="textOne('title blah blah'); textTwo('dimensions blah blah'); textThree('new description blah blah.');"
...or ideally, turn the set into one function that can refer to and change all three texts. Something like:
onclick="textWrite('title blah blah', 'dimensions blah blah', 'description blah blah')"
My absolute beginner's knowledge of javascript is still insufficient to do this without help.
View 8 Replies
ADVERTISEMENT
Jun 9, 2010
Is there way to download only the parts of jquery that we need to reduce the size of the download for our users? For example, we are only using traversal, selectors and manipulation.
View 5 Replies
View Related
Aug 15, 2011
I have a search box which uses AJAX to query a database and return a list of suggestions to the user, it works off the "onkeyup" event on the input textbox.
Code:
<input type="text" id="txt1" onkeyup="showHint(this.value)" />
Obviously this creates an AJAX call for every keypress the user makes and I'd like to make this more efficient by adding a short delay before the AJAX call is made.
View 13 Replies
View Related
Oct 26, 2011
Ive got a hover effect going on when someone hovers over the images on my page which works fine. However on the page load, I would like the first image atmaximum size which is height:101px by width:101px. Ive added the code
$
(
'ul#Magnifine li img:first'
)
[code]....
View 5 Replies
View Related
Jan 7, 2010
I have been trying to link a function to the .innerHTML tag.
<html>
<head>
<script type="text/javascript">[code]...............
View 4 Replies
View Related
Mar 14, 2011
I generate a table with images at back end of php..after that I innerHTML that table to html div tags...In image click event i must want to fire jquary function...In testing time(hard code that table in html page) the function is working nicely ... But same table after innerHTML jquary function is not working...
View 1 Replies
View Related
Jan 27, 2009
Here's the problem: I have several hidden divs containing information. When you click on a link, javascript executes which is supposed to move the appropriate info from one of the hidden divs into the visible 'body' div. The javascript isn't working, though, and I'm getting 'undefined' instead
View 2 Replies
View Related
Oct 15, 2010
I'm having an issue with Firefox and the innerHTML code. My index file has the following html body code in it:
Code:
<div id="testBox" style="text-align: center; color:white;">
test text
</div>
Then, in a separate html document loaded through an iframe, I have the following code that works great in IE but not in Firefox:
Code:
<SCRIPT type="text/javascript">
function ChangeML(){
parent.testBox.innerHTML ='text has been changed';
};
</script>
The function ChangeML is called on a click event using MooTools, but I figured that part isn't what's causing the problems because everything else works fine. No error seems to be reported ... it just skips right over this piece of code.
View 5 Replies
View Related
Jan 29, 2009
I'm designing a website for a mock promotions firm, and currently I have a header, menu-bar (horizontal, sits under the header), a big 'content' main area, and a footer, all arranged in CSS. The problem I'm having, is that I've got an embedded music player in the footer - and now obviously whenever I click on a link in the menu bar to take me to another page, the music re-starts, and looks very unproffessional The header, menu, footer and music parts are the same for every page, so I thought I could just use
document.getElementById("content").innerHTML = "[page code here";
as a JS function mapped to "onclick" of the links in the menu bar. It works for little quick practices, where I put text in the [page code here] for each different page - but here's the crux of the problem: One of the pages has an embedded flash file, a photo-gallery viewer. Here is the code for the 'content' part of this gallery page:
<div id="flashcontent">
You don't seem to have flash installed. <a href="http://www.macromedia.com/go/getflashplayer/">Get It.</a></div>
<script type="text/javascript">
[code].....
I uploaded this onto the webserver and gave it a go - the best I got was a dark box showing up (same colour as the photo gallery background) - Is it because I can't just lump all of that code into a getElementById call ?
View 1 Replies
View Related
Jan 5, 2011
I don't really know how to say this, that's why I'm going to show you some code which will hopefully point out what I mean.This is what I wrote yesterday:
var div = $('<div></div>').attr('id','box').fadeIn(1250);
$('body').append(div);
This worked well, but then I wanted to make a function to be able to change the innerHTML of that div but it didn't work.
function changeContent(content) {
var box = $('#box');
box.html(content);
[code].....
View 2 Replies
View Related
Jul 25, 2011
I am inserting an image into a span tag by click on button and resize the image using resize_image_height_weight function.I am using two function to do this task. code...My purpose is to resize the image.
View 2 Replies
View Related
Jan 23, 2011
why the string comparison test doesn't work in this javascript function? It works if you use just text between the currentItem div tags, but not when you use html for an image. I even tried to use iso characters instead of angle brackets, as in "<img src=expand.png></img>" and still no dice. Why not?
<html>
<head></head>
<body>
<script language="JavaScript">
function toggleValue()
{
if(document.getElementById("currentItem").innerHTML != "<img src=expand.png></img>")
{
[Code].....
View 3 Replies
View Related
Nov 1, 2011
<html>
<head>
<script type="text/javascript">
var a = january
var b = febuary
var c = march
function test()
[Code]...
I tried to explain it pretty well in the comment tags
View 21 Replies
View Related
Mar 16, 2009
Is there a way to add an if and else with in innerHTML like this.
var sfe = document.getElementById("mainform").innerHTML ='<form name="'+frmName+'">'+
'<!-- comment -->'+
'<h2 id="pa" name="dr">';if(n == 1){'+fname+'}else if(n == 2){<b>No Title</b>} '</h2>'+
'more'+
View 4 Replies
View Related
Apr 10, 2006
I'm currently using AJAX to perform some dynamic updates and return some text to the web page. At the moment I'm using innerHTML as follows:
document.getElementById('WrkItemDiv').innerHTML=wrkItemReq.responseText;
but I'd like to be standards compliant. How would I do this using pure DOM stuff?
btw WrkItemDiv is an exisiting <div> I simply want to overwrite the text within it with the newly returned text.
Also, is it possible to change the onMouseOVer code with some text returned in the same way as above using pure DOM?
View 12 Replies
View Related
Oct 22, 2007
I am getting data from two tables in a database using a dropdown box with a onchange and some ajax to update two diferent Div tags, basically the id is passed to a php page,, I grab the data from the two tables, I then echo the data in two html tables. I echo a ** for a delimiter between the two tables,
Then I use a javascript split function to split the responseText into two peices so I can update each DIV with the coresponding data.
Everything works in Firefox, but in IE7 only one div gets updated with its data, the other div will not change, and I get a unknown runtime error. However if I go into my php page and change the data I am echoing after the delimiter to a simple echo 'test' it will work. Code:
View 2 Replies
View Related
Jul 23, 2005
I've got this code that creates a new new row and cell. I then put some
text into the cell with innerHTML - works beautifully with Firefox but
fails with IE. I guess IE doesn't support this way of doing it, but is
there another way of doing it with DOM?
newr = document.createElement('tr');
stbl.appendChild(newr);
newc = document.createElement('td');
newr.appendChild(newc);
newr.cells[0].innerHTML = (nr+1)+". "+sa[ti][nr + 1]+"<br><hr>";
(works in firefox but fails in IE 6+ too...)
View 22 Replies
View Related
Jul 23, 2005
Here is my problem in a nutshell: a script to model dynamic table
extension. It works under Firefox. But IE just aborts, complaining about
an "unknown runtime error" in the line with "innerHTML". Why?
<html><head></head><body>
<script language="javascript">
function extend() {
var tb = document.getElementById('thetable').tBodies[0];
var newrow = document.createElement('tr');
tb.insertBefore(newrow,tb.rows[tb.rows.length-1]);
tb.rows[tb.rows.length-2].innerHTML =
'<td>A</td><td>dummy</td><td>row</td>'
}
</script>
<table id="thetable">
<tr><td>1-1</td><td>1-2</td><td>1-3</td></tr>
<tr><td>2-1</td><td>2-2</td><td>2-3</td></tr>
<tr><td>3-1</td><td>3-2</td><td>3-3</td></tr>
<tr><td colspan="3"><a href="javascript:extend();">extend</a></td></tr>
</table>
</body>
</html>
View 1 Replies
View Related
Jul 23, 2005
IE seems to munge the innerHTML of a document, does anyone know why
it's changing the innerHTML?
<body>
<div style="background-color:LightGrey;" onclick="window.alert( 'one:'
+ getElementById('one').innerHTML );" id="one">
<table id="tableone">
<tr id="trone">
<td>click me</td>
</tr>
</table>
</div>
<div id="two" style="background-color:LightBlue;"
onclick="window.alert( 'two:' + getElementById('two').innerHTML );">
<table id="tabletwo">
<tr id="trtwo">
<td>click me too</td>
</tr>
</table>
<input type="checkbox" checked="checked" value="MYVAL" />
</div>
</body>
View 4 Replies
View Related
Jul 23, 2005
Why doesn't a SELECT element's innerHTML reflected which option was
selected? Works in IE. I need this functionality so that I can retain
what choices a user made in a tabbed interface.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://w3.org/1999/xhtml">
<head>
<script language="javascript">
function callAlert(){
var theHTML = document.getElementById('Radius').innerHTML;
//alert(theHTML);
}
</script>
<title>Untitled Document</title>
</head>
<body>
<form id="myForm">
<div id="myDiv">
<table border="0" width="430" cellpadding="3" cellspacing="0">
<tr>
<td font color="#ff0000">*</font>Radius:</td>
<td width="331" height="30" class="formData">
<select onChange="callAlert();" id="Radius" name="Radius">
<option value=".10" id="0">1/10 mile</option>
<option value=".20">1/5 mile</option>
<option value=".25">1/4 mile</option>
<option value=".5">1/2 mile</option>
<option value=".75">3/4 mile</option>
<option value="1">1 mile</option>
</select>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
View 24 Replies
View Related
Mar 8, 2006
I am using a frameset with two frames that looks like this:
|------------------------------|
| |--------------------------| |
| | FRAME 1 | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| |--------------------------| |
| |
| |--------------------------| |
| | FRAME 2 | |
| | | |
| | <html><body> | |
| | <table><tbody> | |
| | <tr> | |
| | <td>Data 1</td> | |
| | <td>Data 2</td> | |
| | </tr> | |
| | </tbody></table> | |
| | </body></html> | |
| |--------------------------| |
|------------------------------|
FRAME 2 has no height, so it looks as if you only have 1 frame. I am
using FRAME 2 to retrieve data from my server.
I open up FRAME 1 with my webpage and leave FRAME 2 empty. When the
user request data I target FRAME 2 and the data is loaded into FRAME 2.
What I have been trying to do is this. Take the innerHTML of the FRAME
2's table and load it into a table in FRAME 1.
View 1 Replies
View Related
Jul 6, 2006
I want to load an external file into my page via XMLhttpRequest and
innerHTML. The external file contains javascript code which is not executed during
or after insertion. All the HTML markup is displayed just fine....
basicly even this code doesnt work:
<div id='tmp'>original Content</div>
<script>
document.getElementById("tmp").innerHTML="<b>new</b>
Content<script>alert('not shown! why?');</script>";
</script>
looking at the page, "new Content" is shown with "new" bold as
expected, but there wont be the javascript alert!
View 1 Replies
View Related
Jul 19, 2006
I use Ajax to retrieve part of a page I need to update. I update a DIV
element with the HTML contents I get from another page.
It works fine.
However the HTML have a SCRIPT tag that the browser should process, but
it doesn't.
Here's an example:
--- pageX.aspx ---
<table>
<tr>
<td>Table 01</td>
</tr>
</table>
<script>
alert("HI");
</script>
--- end pageX.aspx ---
--- page on browser ---
<div id="divContents"></div>
<script>
divContents.innerHTML = getHtmlFromPage("pageX.aspx");
</script>
--- end page on browser ---
When the prowser gets the "pageX.aspx" and updates the contents of the
'divContents' it displays the table, but it didn't process the script.
What am I doing wrong?
View 17 Replies
View Related
Sep 29, 2006
What debugger would let me see the HTML in a div after I've added HTML
to the div using its innerHTML? That is:
var someInputHtml = prompt("input html");
var referenceToSomeDiv = document.getElementById("someDiv");
referenceToSomeDiv.innerHTML = someInputHtml;
When debugging, how do I now see what HTML is in the div "someDiv"?
Maybe there is a FireFox extension for this? Firebug?
View 5 Replies
View Related
Apr 27, 2007
if i use AttachEvent like this,it can't work;
eg:
var img = document.createElement("img");
img.attachEvent("onclick",alert("test"));
var div = document.createElement("div");
div.appendChild(img); //can't work;
div.innerHTML="<-click this";
but i use attachEvent like this,it work; eg:
var img = document.createElement("img");
img.attachEvent("onclick",alert("test"));
var text = document.createElement("span");
text.innerHTML="<-click this";
var div = documet.createElement("div");
div.appendChild(img); //can work
div.appendChild(text);
View 6 Replies
View Related
Jul 20, 2005
Is there any way to use a variable.innerHTML = ""; instead of text.innerHTML
= "";? It doesn't seem to work for me.
View 2 Replies
View Related