Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

Html split(text) Part2

Hi experts, I wish to get the data in input text who's id="ii" and put it in a textbox separately by split via "/". I want that Whing will be put on iA,  Delacruz on iB, 88 on iC, and 22 on iD. Thank you!

 
<!DOCTYPE html>
<html>
<body>

<input type="text" id="ii" value="Whing/Delacruz/88/22"><br/>
<button onclick="myFunction()">Try it</button><br/><br/>

<input type="text" id="iA"><br/>
<input type="text" id="iB"><br/>
<input type="text" id="iC"><br/>
<input type="text" id="iD"><br/>

<p id="demo"></p>

<script>
function myFunction() {
    var str = document.getElementById("ii").value;
  
    var res = str.replace(/\//g);

    document.getElementById("iA").value = ;
    document.getElementById("iB").value = ;
    document.getElementById("iC").value = ;
    document.getElementById("iD").value = ;
}
</script>

</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Whing Dela Cruz

ASKER

Hi Monty, it seems not working but I will double check it now!
Hi Monty the reference res(0), res(1), res(2), res(3) is not working here... Thanks!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Jason, Its working..
Thank you so much both of you guys, more power and God bless you both!