I am sending multiple values from the input field with the same name. It works fine when I just send the custom1 and var 2 but I want to add a javascript variable var3 as well but assigning the value by using document.getElemendById overwrites the input field completely and custom1 and var2 are lost. So how to add a javascript variable var3 at the end so it gets printed under the array index $pieces[2]; in the v.php file.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php $var2 = "custom2" ?>
<form action="v.php" method="POST" >
<input id="jsvar" type="text" name="custom" value="custom1,<?php echo $var2; ?>">
<input type="submit" name="" value="send">
</form>
<script type="text/javascript">
var var3 = "custom3";
document.getElementById("jsvar").value = var3;
</script>
</body>
</html>
v.php
<?php
$custom = $_POST['custom'];
$pattern = ",";
$pieces = explode($pattern,$custom, 3);
print_r($pieces);
$custom1 = $pieces[0];
$custom2 = $pieces[1];
echo '<br>';
echo $custom1.'<br>';
echo $custom2.'<br>';
echo $pieces[2];
?>
jsvarin your form?