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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    HTML & JS - undefined input

    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:
    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
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Change this
    Code:
    oLink.title = title
    	  var title = GetE('txtTitleLightBox').value = title;
    to this
    Code:
    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.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Didn't help... It's still undefined :s

    Thanks anyway


  •  

    Posting Permissions

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