Skip to content

Instantly share code, notes, and snippets.

@WenLiangTseng
Last active December 20, 2015 01:39
Show Gist options
  • Save WenLiangTseng/6050566 to your computer and use it in GitHub Desktop.
Save WenLiangTseng/6050566 to your computer and use it in GitHub Desktop.
讓HTML的一個Option取多個數值
<!-- put values for each options like -->
<SELECT NAME="val">
<OPTION VALUE="1" value="1:2:3:4"> 1-4
<OPTION VALUE="2" value="5:6:7:8"> 5-8
<OPTION VALUE="3" value="9:10:11:12"> 9-12
</SELECT>
<?php
//at server side in case of php, use functions like
//explode [array] = explode([delimeter],[posted value]);
$values = explode(':',$_POST['val']);
$values[0];
$values[1];
//etc.
//the above code return an array have only the numbers
//and the ':' get removed
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment