Hello,
Well, it be better to clarify your case.
I guessed the following situation:
In your textbox you have a list of values - it is actually a string and you need to use JS function split.
See
I did the following changes in your code:
<HTML>
<HEAD>
<TITLE>Script</TITLE>
</HEAD>
<BODY>
<form name="eventform">
<input type=text name="pubishedid" value="1,2,3,4,5">
</form>
<script>
alert(document.eventform.pubishedid.value);
var pubishArray = document.eventform.pubishedid.value.split(',');
alert(pubishArray[0]);
alert(pubishArray[1]);
alert(pubishArray[2]);
</script>
</BODY>
</HTML>
Keep in mind that insuch way array values are strings, not integers. If you need to add some of them, youhave to use
parseInt(pubishArray[0]) + parseInt(pubishArray[2]) in order to get the integer result.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.