• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

How do I parse a value in CGI

 If I have a Drop-Down Combo box on a form ( such as Number of Employees ), with values like 1-15, 16-30, etc...
How do I parse the values into 2 seperate variables so I can check if it is within a range?

  Example code would be appreciated...
1 Solution
What language ? Perl, ASP, C++ ?
Most languages have a split function which works something like this.

NewVars = split(your_string,"-")
FirstVar = NewVars(0)
SecondVar = NewVars(1)

But it is easier to change the dropdown box:

<option value="1">1-15
<option value="2">16-30

You can name the values the way you want it and in the responding cgi process the data accordingly.

One way to do that (for perl) would be:

($lval,$hval) = split /-/,$value;

if ($hval < 15) {

elsif ($hval < 30) {

else {


where $value is 1-15, or 16-30, or the like.
johnsandAuthor Commented:
That's exactly what I needed MITEK...  Thanks...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now