SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Belgium
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    setting textarea value

    hello,

    I'm really stuck here with setting a value in textarea.
    My currect thing works in IE, but not in Firefox/Mozilla
    Can anybody help me with this? The current thing is:

    Code:
    function buildHtml(type) {
    	width = document.getElementById('imgWidth').value;
    	height = document.getElementById('imgHeight').value;
    	source = document.getElementById('imgPath').value;
    	switch (type) {
    	case 'left':
    		document.frmImage.taHtml.value = '<img alt="" align=left height="'
    			+ height + '" width="' + width + '" src="' + source + '" class=intext>';
    	break
    	case 'right':
    		document.frmImage.taHtml.value = '<img alt="" align=right height="'
    			+ height + '" width="' + width + '" src="' + source + '" class=intext>';
    	break
    	case 'center':
    	default:
    		document.frmImage.taHtml.value = '<div align=center>\n<img alt="" height="'
    			+ height + '" width="' + width + '" src="' + source + '" class=intext>\n</div>';
    	break
    	}
    }
    // .....
    <form method="post" name="frmImage">
    	<img src="./../images/imgmiddle.gif" onClick="buildHtml('center');" alt="Align center" width="16" height="15">&nbsp;
    	<img src="./../images/imgleft.gif" onClick="buildHtml('left');" alt="Align left" width="16" height="15">&nbsp;
    	<img src="./../images/imgright.gif" onClick="buildHtml('right');" alt="Align right" width="16" height="15">&nbsp;
    
    	<textarea cols="52" rows="7" name="taHtml"></textarea>
    	<input type="hidden" name="imgWidth" value="150">
    	<input type="hidden" name="imgHeight" value="100">
    	<input type="hidden" name="imgPath" value="<?= '{site_root}'.substr($_GET['img'],$len) ?>">
    </form>
    Well thank you very much in advance!
    Last edited by Tomba; Jun 28, 2004 at 04:10.

  2. #2
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It was your width, height source assignments. Firefox was complaining that width 'imgWidth' had no properties. The problem was that you had to reference the elements from within the form object just as you did with the textarea ... they are a part of the form and need be referenced as such.

    Code:
        var width = document.frmImage.imgWidth.value,
        height = document.frmImage.imgHeight.value,
        source = document.frmImage.imgPath.value;

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    Belgium
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot!

    any hints how I should debug javascript in Firefox?
    I guess there must be some way, but don't know at all

    EDIT: Found it here: http://www.sitepoint.com/forums/showthread.php?t=176570

  4. #4
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's the javascript console. Much better than anything ie ever had. You can access it quickly by clicking the face in the right hand corner:
    http://www.xdevdesign.com/screens/console.gif

    The happy face means no errors, but if you see the red mad face instead you know there's errors on the page. Either way, clicking on the face image takes you to the console. As you can see from the screen, it records all the errors from recent visited webpages until I clear the display. Even them old errors than were recorded from past pages I was on, I could click any one of them right now and would be taking to the offending line in the source code for that particular page.

    In case your wondering about the theme I'm using, its called mostly crystal:
    http://www.tom-cat.com/mozilla/


Bookmarks

Posting Permissions

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