如何在我的javascript中分隔参数值

时间:2015-03-18 11:40:22

标签: javascript

从php我已将值发送到onclick事件。这是我通过onclick('Class I-V Tuition,Class VI-VIII Tuition,College Level,engg,)发送的参数值。

如何在javascript参数中分开?我已经给出了我的输出。

根据我的情况,我需要验证表单字段。如何在javascript中执行此操作?

我在,添加了值,我不知道如何删除最后一个参数中的,以及如何分隔参数值。

我请求堆栈团队给出可能的答案。

if(class I-V)
{
    some validation here
}
if(College Level)
{
    some validation here
}

同样明智的我需要做一些验证。

注意:在我的论证中,我将,

附加值
Here is my form
<?php
if (isset($_POST['tutorsubject']))
{
$v='';
$product = $_POST['segment'];
$_SESSION["segment"] = $product;
foreach($product as $val)
{
$v.=$val.',';
}
print_r($product); 
$people = array("Class I-V Tuition", "Class VI-VIII Tuition", "Class IX-X Tuition", "Class XI-XII Tuition","College Level","Engineering Subjects","Technology");for($i=0; $i<count($product); $i++){
if (in_array($product[$i], $people)) {
if($product[$i]=="Class VI-VIII Tuition"){
<tr>
<Td></Td>
<td><p style="color:#06F;"><?php echo $product[$i];?></p></td>
</tr>

<tr>
<td><p style="color:#999; font-size:14px; text-align:right;">Please select your Board :</p></td>
<td>      <input type="checkbox" name="eightboard[]"  value="cbse" >CBSE
<input type="checkbox" name="eightboard[]"  value="cse/Ise">ICSE/ISE
<input type="checkbox" name="eightboard[]"  value="State">State
<input type="checkbox" name="eightboard[]"  value="International">International
</td>
</tr>
<tr>
<td><p style="color:#999; font-size:14px; text-align:right;">Please select Subject :</p></td>       
<td>      
<input type="checkbox" name="classeightsubject[]"  value="allsubject" >All Subject
<input type="checkbox" name="classeightubject[]"  value="science">Science
<input type="checkbox" name="classeightsubject[]"  value="maths">Maths
</td>
</tr><!--end of select subject row-->
<?php
}
if($product[$i]=="Class IX-X Tuition"){
?>
<tr>
<Td></Td>
<td><p style="color:#06F;"><?php echo $product[$i];?></p></td>
</tr>
<tr>
<td><p style="color:#999; font-size:14px; text-align:right;">Please select your Board :</p></td>
<td>      <input type="checkbox" name="tenthboard[]"  value="cbse" >CBSE
<input type="checkbox" name="tenthboard[]"  value="cse/Ise">ICSE/ISE
<input type="checkbox" name="tenthboard[]"  value="State">State
<input type="checkbox" name="tenthboard[]"  value="International">International
</td>
</tr>
<Tr>
<Td colspan="2" align="center"><input type="submit" name="s" value="Proceed to Next Step"   style="width:200; background-color:#0000CC;color:#FFFFFF; height:30px;" onclick="return valid('<?php echo $v ?>')" ></Td>
</Tr>
<?php
}
?>
</form>

0 个答案:

没有答案