Solved

How do I parse a value in CGI

Posted on 1998-08-04
3
139 Views
Last Modified: 2013-12-25
 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...
0
Comment
Question by:johnsand
3 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 1831333
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:

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

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



0
 
LVL 4

Accepted Solution

by:
mitek earned 10 total points
ID: 1831334
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.
 
0
 
LVL 1

Author Comment

by:johnsand
ID: 1831335
That's exactly what I needed MITEK...  Thanks...
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now