Textbox Changes Dynamically

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
MeroD
New php-forum User
New php-forum User
Posts: 53
Joined: Wed Oct 10, 2012 12:14 am

Re: Textbox Changes Dynamically

Post by MeroD » Mon Nov 12, 2012 10:46 pm

Have you tried:
document.getElementById("textboxelement").innerHTML = "Changed text!";

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: Textbox Changes Dynamically

Post by seandisanti » Tue Nov 13, 2012 9:28 am

1) you're not going to set a value without returning a value from the function
2) there are a lot of ways to do what you're trying, here's a jquery solution that works for me.

Code: Select all

<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
  $("#t1").click(function(){
    $("#t1").val(returnText$("#t2").val()));
  });
  $("#t2").click(function(){
    $("#t2").val(returnText$("#t1").val()));
  });
});
</script>
<script type="text/javascript">
function returnText(str)
{
switch (str) {
   case ""   : str="VG";
               break;
   case "VG" : str="G";
               break;
   case "G"  : str="P";
               break;
   case "P"  : str="N";
               break;
   case "N"  : str="";
               break;
   default   : str="";
               break;
   }

   return str;
}

</script>
</head>

<body>
<form name=f1 action="#" method="post">
<input type="text" id="t1" />
<input type="text" id="t2" />
</form>
</body>
</html>


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest