Hi All, What I tring to do is split 10 digits from var message="10101010111" These numbers consist of 0's and 1's. Binary System. The user enters some numbers that we give them "Say" 10101010111. For this example I am writing the var =message"10101010111" to work out the problem I am having. My problem starts here: When I run this javscript my Mytextbox displays "Undefined!. In the javascript source code section! I have 'Mytextbox.value=Message[1]; inside the []'s I write a 1 like this [1], the 1 in the []'s should extract the 0 because its character number 0 ' selstart in the var array - [message=100101001010. what I should see' should be a '0' But its not, as I mentioned before, mytextbox displays "undefined". Mytextbox.value=Message[1]; <!---when this is working I should see a 0 --- changing the [1] like this [0] I should get a 1 now first character in my array. Appreciated any help, thanks <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>Untitled Document</title> <script type="text/javascript"> onload=function(){ var Message="1010101010111"; var Mytextbox=document['myform']['mytextbox'] <!---this is the textbox I use to display the selected character/number Mytextbox--> Mytextbox.value=Message[1]; <!-- I get "Undefined" not a number???--> } </script> </head> <body> <form action="" name="myform"> <input type="text" name="mytextbox" value="5"> <input type="text" name="textbox=" value="5"> </form> </body> </html> I am a Newbie to Javascript
Well I was playing around with the code: and got it to work <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <title>Untitled Document</title> <script type="text/javascript"> function Binary() { var Message="1001010110"; Binary1.value=Message.charAt(0); Binary2.value=Message.charAt(1); Binary3.value=Message.charAt(2); Binary4.value=Message.charAt(3); Binary5.value=Message.charAt(4); Binary6.value=Message.charAt(5); Binary7.value=Message.charAt(6); Binary8.value=Message.charAt(7); Binary9.value=Message.charAt(8); Binary10.value=Message.charAt(9); } </script> </head> <body onload="onclick= Binary()"> <input id="Binary1" type="text" value="" style="width:50px"/> <input id="Binary2" type="text" value="" style="width:50px"/> <input id="Binary3" type="text" value="" style="width:50px"/> <input id="Binary4" type="text" value="" style="width:50px"/> <input id="Binary5" type="text" value="" style="width:50px"/> <input id="Binary6" type="text" value="" style="width:50px"/> <input id="Binary7" type="text" value="" style="width:50px"/> <input id="Binary8" type="text" value="" style="width:50px"/> <input id="Binary9" type="text" value="" style="width:50px"/> <input id="Binary10" type="text" value="" style="width:50px"/> </form> </body> </html>