...

View Full Version : Help with function



sherlockturtle
09-06-2011, 04:48 AM
Im not sure how to do this so i need your guyses help. Im trying to make a function that copys a text box value to a other text box value but only copy a specific part of the text boxs text. Sorry if i didint write the question well, i can try to post some code if needed.

jmrker
09-06-2011, 05:11 AM
...oxs text. Sorry if i didint write the question well, i can try to post some code if needed.

That would be nice!

xelawho
09-06-2011, 05:25 AM
What you really have to decide is *which* specific part of the text you want to put into the other text box. The code below looks for a dash - in a text and splits it in two there, putting the two halves into two boxes.


<!DOCTYPE html>
<html>
<head>
<title>boxsplit</title>
<meta charset="UTF-8">
<script type="text/javascript">
function splitBoxes() {
str=document.getElementById('tb1').value;
document.getElementById('tb2').value=str.split("-")[0];
document.getElementById('tb3').value=str.split("-")[1];
}
</script>
</head>

<body>
<input id="tb1" type="textbox"></input>
<input type="button" value="Split!" onclick="splitBoxes()">
<input id="tb2" type="textbox"></input>
<input id="tb3" type="textbox"></input>
</body>
</html>

but without further details about what you want to do, it's hard to see how to be of much more help...

sherlockturtle
09-06-2011, 11:32 PM
thanks xelawho



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum