问题描述:

When I'll use in the php form this code

 <option value="foo|bar">foo</option>

than how to receive the part 'foo' and the part 'bar'?

网友答案:

Assuming your select tag has the name mySelect, you can assign them to the array $split_values in php using

$split_values = explode("|", $POST_["mySelect"]);

You can then access the foo part with $split_values[0] and the bar part with $split_values[1].

网友答案:

I'm not sure what you mean, but something like "foo|bar".split('|')[0]?

网友答案:

you can do it with assignment id to option tag and:

<option id="test" value="foo|bar">foo</option>

some javascript code:

var option_val = document.getElementById('test').value;
alert(option_val.split('|', 2));
相关阅读:
Top