Jump to content

problem with function..


jasonc

Recommended Posts

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>

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.