Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Undefined error

  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Undefined error

    Hi,

    I'm not sure did I post this to the right area, 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:
    Code:
    					<div>
    					  <br />
    					  <input id="txtTitleLightBox" style="width: 100%" type="text" />
    					</div>
    And these are the modified codes which I added to the js file:
    Code:
    	  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;
    	    }
    	  }
    Code:
    	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
    Code:
    	  oLink.title = title
    	  var title = GetE('txtTitleLightBox').value = title;
    and
    Code:
    	      GetE('txtTitleLightBox').value= title;
    The result is (eg) this kind of html text:
    Code:
    <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

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Didn't you already post this question?

    Here's what I see:
    Code:
    	  oLink.title = title
    	  var title = GetE('txtTitleLightBox').value = title;
    Concerning the title highlighted in red, where is that defined before you use it?
    Are you a Help Vampire?

  • #3
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ... nowhere

    So should I add under
    Code:
    	    {
    	      rel = rad[i].value;
    	      break;
    	    }
    something like
    Code:
    	    {
    	      title = rad[i].value;
    	      break;
    	    }
    I'm so sorry that even I'm a total dummy, I trie to modify something myself... :s

    And whoops, yes I did post this question already... Sorry

  • #4
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    I doubt it. Does that radio button contain the desired title text? If not, no.

    What confuses me is why you're attempting to set the link title (I guess) with this:
    Code:
    oLink.title = title
    But then redefine the title variable immediately after it with this:
    Code:
    var title = GetE('txtTitleLightBox').value = title;
    Is there some method to this madness or are you just copy/pasting junk around because you don't know what you're doing? If the latter, you might rather want to swap the order of those two lines.
    Are you a Help Vampire?

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Ummm...

    This line:
    Code:
    var title = GetE('txtTitleLightBox').value = title;
    will *NOT* modify the value of the variable named title.

    It assigns the *existing* value of title to the form field (or whatever that is) and then *RE-ASSIGNS* it right back into...the variable title.

    *Possibly* this would work:
    Code:
    var title = GetE('txtTitleLightBox').value; // *GET* the value from the form field...
    oLink.title = title; // must be *AFTER* defining the variable
    But who knows?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    woncler (06-18-2010)

  • #6
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Well, that shows how well I pay attention. I didn't even see that assignment dangling off the end. I blame it on the access control list code I've been staring at all week. Yeah, that's it.
    Are you a Help Vampire?

  • #7
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I love youu ♥_♥ It's working perfectly now. If you're interested what I did, I added this code
    Code:
    	    {
    	      title = txt.value;
    	      break;
    	    }
    and that code, which Old Pedant sent.

    I know that it is very stressful when people like me come and ask completely stupid questions... Thanks for your patience.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •