I'm showing in a field the name of the file the user has chosen. I would like to show the whole name as the title when passing the mouse over the field, in case the name is too long.

I swear this was working, but it's not anymore (I'm testing with FF). I don't know how it was working, maybe I used a different combination of quotes or semicolons or I don't know. I can't make it work again. When you pass de mouse over the field it is showing the code instead of the innerHTML referenced:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">

<script type="text/javascript">

function newField()
document.getElementById('container').innerHTML = 
	'<div id="myFile" style="width:100px;overflow:hidden;border:thin solid" title="document.getElementById(\'myFile\').innerHTML">thisisaverylongfilename.jpg</div>';

<body onload="newField()">
	<div id="container" />


Edited by Altairzq: n/a

7 Years
Discussion Span
Last Post by Jupiter 2

Change your function as shown below

function newField()
document.getElementById('container').innerHTML = '<div id="myFile" style="width:100px;overflow:hidden;border:thin solid" title=\'' + document.getElementById('myFile').innerHTML+ '\'>thisisaverylongfilename.jpg</div>';

You may use document.getElementById('myFile').innerText


Back in the old days of Javascript the Quote marks would be the outer marks of the reference and anything inside that required quote marks, used apostrophes. It seems thing have changed and it's the reverse action now?


It's not working either, it gives an error because the field "myFile" doesn't exist yet.

It was working when I created the field from PHP-Ajax, could that be it? But if there wasn't Javascript involved how could it interpret the code? :confused:

This is the piece of code I used, more or less. This one is not working:

	<td />
	<td colspan='3' style=\"padding-bottom:4px\">
		<div id='escollitOriPri' style=\"height:14px;text-align:center;font-size:11px;overflow:hidden;cursor:default\" title=\"document.getElementById('escollitOriPri').innerHTML\">

Edited by Altairzq: n/a


This is my interpretation, as to how it "used" to be done but new coding might be different to what I've learnt.

<tr><td colspan=3 style=padding-bottom:4px>
<div id="escollitOriPri" style="height:14px;text-align:center;font-size:11px;overflow:hidden;cursor:default; title=document.getElementById('escollitOriPri').innerHTML"></div></td></tr>

colspane = 3 A number is not enclosed in quotes as it is a number and not text.

I do not know the reference of backslash for the style tags.
The only thing is if the title tag within the div tag is supposed to be there or in its own enclosures.
I'd be interested to see if my modifications work within your sheet.

Edited by Jupiter 2: Quote marks


colspane = 3 A number is not enclosed in quotes as it is a number and not text.

In case you're interested, this isn't necessarily correct. Actually, I think I recall that if you use XHTML you MUST enclose everything in quotes (even empty literals). Using <button disabled>test</button> is also not legal using XHTML, you have to set <button disabled="disabled">test</button> if I recall correctly.

Also, in old HTML you had the OPTION of leaving off quotes at simple input. But it's nothing to worry about actually 'cause all normal browsers don't care anyway :-), but if you want to follow the new standards, always use quotes, and always close every tag (even br: <br /> .

<br />

I don't know what this means. Break actually doesn't have an "end break" tag. Break is just like a line return except it returns the cursor to the left margin new line.


The Paragraph tag requires (but not usually implemented) an End Paragraph as it is a specific format. It inserts a line space between "paragraghs."


Edited by Jupiter 2: typas


It's not an end break tag (the / is at the end of the tag). Whenever (in XHTML as said) you have empty tags (like br, hr, img and meta) you should close them using the shorthand-syntax. <p id="a1"></p> is in theory equivalent to <p id="a1" /> . Problem is that tags that aren't normaly empty by some reason isn't read as XHTML (this might be because XHTML requires the browser to fail if it finds errors in the markup if I'm not mistaken). But always-empty tags do require this syntax.

Therefore you have

<br />
<hr />
<img href="..." />

And one more thing, all tagnames and attributes should be lowercase.


I think you have forgotten to close the container div. Your code should work with the div closed!


I looked up XHTML and the closing bracket is correct. I'm an old hack from way back and just used to old HTML code.
In Post #4, the 2nd line refers to a closing td but no open td? Maybe somewhere above that you did not inlcude?

	<td />	
<td colspan='3' style=\"padding-bottom:4px\">		
style= \"padding .... Shouldn't the Quote marks start before the backslash?

I"m new to this so I'm only making suggestions. I'm a bit out of my depth with xhtml. I still use HTML hard code by hand so xhtml is not part of my repertoire.

This is my last post on this subject.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.