Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,563 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,388 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



finding the errors in this function

 
Reply to this topicStart new topic

finding the errors in this function

hiphop_13
post 20 Jul, 2008 - 05:32 PM
Post #1


New D.I.C Head

*
Joined: 4 Jun, 2007
Posts: 36



Thanked 1 times
My Contributions


Hi i've been trying this script n i have some questions
CODE


<script language='javascript'>
spell_img = new Image();
spell_img.src = '/images/standard/spellcheck.gif';
spell_img.setAttribute('title',_lang_spellcheck );
function find_text_boxes()
{
myforms = document.forms;
for( i=0;i < myforms.length; i++ )
{
textareas = myforms[i].getElementsById('textarea');
for( y=0; y < textareas.length; y++ )
{
spelllink = document.createElement('a');
spelllink.setAttribute('href',"java script:spellCheck(" + i + ", '" +
textareas[y].name + "')");
spelllink.appendChild( spell_img.cloneNode(true) );
textareaParent = textareas[y].parentNode;
textareaParent.insertBefore( spelllink, textareas[y].nextSibling );
}
}
}
</script>

i have 2 questions:
What r the errors & how can i fix them?
How many images will this create and where will it place them?
Thanks
User is offlineProfile CardPM

Go to the top of the page


ahmad_511
post 23 Jul, 2008 - 04:02 PM
Post #2


D.I.C Regular

Group Icon
Joined: 28 Apr, 2007
Posts: 351



Thanked 8 times

Dream Kudos: 400
My Contributions


Hi,

the two errors:

QUOTE
spell_img.setAttribute('title',_lang_spellcheck );

is _lang_spellcheck avariable?if it's so it must be defined first, if not you must to quote it with single or double quotes
jscript
spell_img.setAttribute('title','lang_spellcheck');


QUOTE
textareas = myforms[i].getElementsById('textarea');

it's getElementById without (s) , but since you typed (textarea) I presume that you mean getElementsByTagName()
jscript
textareas = myforms[i].getElementsByTagName('textarea');


the images count must matches the textarea's count and it will placed next to the text area

I hope it helps
User is offlineProfile CardPM

Go to the top of the page

huzi8t9
post 28 Aug, 2008 - 06:10 AM
Post #3


New D.I.C Head

*
Joined: 11 Jul, 2007
Posts: 20


My Contributions


CODE

spell_img = new Image();
spell_img.src = '/images/standard/spellcheck.gif';
spell_img.setAttribute('title',_lang_spellcheck );
function find_text_boxes()
{
myforms = document.forms;
for( i=0;i < myforms.length; i++ )
{
textareas = myforms[i].getElementsById('textarea');
for( y=0; y < textareas.length; y++ )
{
spelllink = document.createElement('a');
spelllink.setAttribute('href',"java script:spellCheck(" + i + ", '" +
textareas[y].name + "')");
spelllink.appendChild( spell_img.cloneNode(true) );
textareaParent = textareas[y].parentNode;
textareaParent.insertBefore( spelllink, textareas[y].nextSibling );
}
}
}


try-catch

CODE

try
{
spell_img = new Image();
spell_img.src = '/images/standard/spellcheck.gif';
spell_img.setAttribute('title',_lang_spellcheck );
function find_text_boxes()
{
myforms = document.forms;
for( i=0;i < myforms.length; i++ )
{
textareas = myforms[i].getElementsById('textarea');
for( y=0; y < textareas.length; y++ )
{
spelllink = document.createElement('a');
spelllink.setAttribute('href',"java script:spellCheck(" + i + ", '" +
textareas[y].name + "')");
spelllink.appendChild( spell_img.cloneNode(true) );
textareaParent = textareas[y].parentNode;
textareaParent.insertBefore( spelllink, textareas[y].nextSibling );
}
}
}
}
catch(e)
{
alert(e.description);
}


This post has been edited by huzi8t9: 28 Aug, 2008 - 06:10 AM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 11:28PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month