...

View Full Version : HTML & JS - undefined input



woncler
06-16-2010, 11:47 AM
Hi,

I'm not sure did I post this to the right topic, but here's my problem...

Let's make this simple, I am totally newbie in coding.

I installed a lightbox patch to FCKeditor, and I tried to modify it a bit so I could add a title into it. I kind of managed but...

Here's the html code which I added to the html file:

<div>
<br />
<input id="txtTitleLightBox" style="width: 100%" type="text" />
</div>

And these are the modified codes which I added to the js file:

var rel = oLink.rel;
if (rel)
{
var type;
if (rel.indexOf("[") > 0)
type = rel.substring(0,rel.indexOf("["));
else
type = rel;
var oE = GetE('rad'+type);
if (oE)
{
GetE('txtTitleLightBox').value= title;
GetE('txtGroupLightBox').value= rel.substring(rel.indexOf("[")+1, rel.indexOf("]"));
GetE('chkLightBox').checked = true;
GetE('rad'+type).checked = true;
}
}

if (GetE('chkLightBox').checked && oLink)
{
var rel = "lightbox"
var rad = document.getElementsByName('radLightBoxType')
for (var i=0; i < rad.length; i++)
{
if (rad[i].checked)
{
rel = rad[i].value;
break;
}
}

oLink.title = title
var title = GetE('txtTitleLightBox').value = title;
oLink.rel = rel
var group = GetE('txtGroupLightBox').value
if (group)
{
oLink.rel += "[" + group + "]"
}
}


And what I added as new code were

oLink.title = title
var title = GetE('txtTitleLightBox').value = title;
and

GetE('txtTitleLightBox').value= title;

The result is (eg) this kind of html text:

<a title="undefined" rel="lightbox" href="image/path"><img width="200" height="113" alt="" src="image/path" /></a>
So the title is undefined even if I fill something to the txtTitleJavaScript box...

If you want to investigate the full files, they are here:

http://jump.fm/IYOXH

.. thanks :s

_Aerospace_Eng_
06-16-2010, 03:27 PM
Change this

oLink.title = title
var title = GetE('txtTitleLightBox').value = title;

to this

var title = GetE('txtTitleLightBox').value = title;
oLink.title = title

What might be happening is title isn't defined yet so that is why you get undefined.

woncler
06-16-2010, 03:51 PM
Didn't help... It's still undefined :s

Thanks anyway



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum