Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to split textbox1 dispayed data (10000223--DOMPARIDINE) into 2 textboxes

textbox2 textbox3
10000223 DOMPARIDINE

Thank You

help me any one...
Posted

Use JavaScript String split() Method[^]
example:
XML
<!DOCTYPE html>
<html>
<body>

<input type="text" id="textbox1" value="10000223--DOMPARIDINE">
<input type="text" id="textbox2" value="">
<input type="text" id="textbox3" value="">

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    var text1 = document.getElementById("textbox1").value;
    var result = text1.split("--");
    document.getElementById("textbox2").value = result[0];
    document.getElementById("textbox3").value = result[1];
}
</script>
</body>
</html>
 
Share this answer
 
v2
function setvalue() {
var text = $('#textbox1').val();
var result = text.split('--');
$('#textbox2').val(result[0]);
$('#textbox3').val(result[1]);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900