jasonc Posted April 3, 2009 Share Posted April 3, 2009 i have tried and just no idea what i do, i do not know much about javascript. this is my code and i am trying to have it so when the 'swap' link is clicked it swaps the content of the two fields, i just get an error saying that something is not defined, thisField.FieldID1 <html> <head> <title>test_move_box_content.php</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <SCRIPT type="text/javascript" LANGUAGE="JavaScript"> function MoveBoxContent(thisField, FieldID1, FieldID2) { var temp = thisField.FieldID1.innerHTML; this.FieldID1.value = thisField.FieldID2.innerHTML; this.FieldID2.innerHTML = temp; } </script> <style type="text/css"> <!-- div.boxedarea { border: 1px solid #fff; position: align: center;} a.boxedarea { text-decoration: none; color: #777777; } --> </style> </head> <body> <div style="text-align: center;"> <form name="form1" method="post" action=""> <? $j = 2; for ($i = 1; $i <= $j; $i ++) { ?> <div class="boxedarea"> <br><textarea id="<?=$i;?>" name="<?=$i;?>" cols="80"></textarea><br> <? if ($i < $j) { ?><a class="boxedarea" href="#" onClick="MoveBoxContent(this, <?=$i;?>, <?=$i-1;?>);">swap</a><? }?> </div> <? } ?> </form> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
Floydian Posted April 4, 2009 Share Posted April 4, 2009 It looks like you're passing a number to FieldID1. thisField --- That var would be an anchor element thisField[xxxxx] where xxxx is whatever number is contained in FieldID1 would not be pointing to an element, and thus, it has not innerHTML property Hope that helps... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.