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

Submitting values

<input type="checkbox" name="multilingual" value="english" >english
<input type="checkbox" name="multilingual" value="dutch" >dutch
<input type="checkbox" name="multilingual" value="french" >french
<input type="checkbox" name="multilingual" value="german" >german

In a script I use the checkbox option above.

When I submit the script:
The value $in{'mulitilingual'} becomes:
english dutch french german.

It looks like that the value are seperated by a space.
But I think it isn't so.

When I added the script manual and set the seperator to a space the script works fine. Further on in the script the value $in{'mulitilingual'} will be split using a space as a seperator!!

When the script will try to split the value made by the form the value $in{'mulitilingual'} will not be split but stays as one value:
english dutch french german

Can someone help me??

greetings Michel

0
mmcw
Asked:
mmcw
  • 5
  • 4
  • 2
1 Solution
 
hualianCommented:
Hi.

I Think the best method is use CGI
only need 6 line. all you want.

a.cgi

use CGI;
$q=new CGI;
print $q->header;
print $q->start_html;
print $q->param('multilingual');
print $q->end_html;

ofcourse. you may say: i don't want use
CGI.

the another way to do:
you use your orginal script,and recive
the var from the forms. you get one var
with space. you add  follow line:
$youvar=~s" "";
$youvar now have not space seprate.

may be this can give help for you.


ok. if you still have problem,please ask again
0
 
mmcwAuthor Commented:
The problem is I get one variable from the form. It looks like there are spaces between each options. But when I try to split them by using the space to split it will not work!!!!!!

I think the form does not use spaces???
0
 
hualianCommented:
first you get the variables into one
var.

then use ~s to replace it.

or use split.

i recommd you had better use one var get the variable from the form.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
hualianCommented:
first you get the variables into one
var.

then use ~s to replace it.

or use split.

i recommd you had better use one var get the variable from the form.

if you still have problem,you can show me some code of this script.

thank you..
0
 
ozoCommented:
How is %in set in your script?
0
 
mmcwAuthor Commented:
Answer to ozo:
I use cgi-lib
0
 
ozoCommented:
What version?  Could you post the relevent code?
I think most will separate the values with "\0" in a single scalar string
if you use CGI.pm, (which I'd recommend) it will return the parameters in an array.
0
 
mmcwAuthor Commented:
This is the version that is used by my script!

# Perl Routines to Manipulate CGI input
# S.E.Brenner@bioc.cam.ac.uk
# $Id: cgi-lib.pl,v 2.8 1996/03/30 01:36:33 brenner Rel $
#
# Copyright (c) 1996 Steven E. Brenner  
# Unpublished work.
# Permission granted to use and modify this library so long as the
# copyright above is maintained, modifications are documented, and
# credit is given for any use of the library.
#
# Thanks are due to many people for reporting bugs and suggestions
# especially Meng Weng Wong, Maki Watanabe, Bo Frese Rasmussen,
# Andrew Dalke, Mark-Jason Dominus, Dave Dittrich, Jason Mathews

# For more information, see:
#     http://www.bio.cam.ac.uk/cgi-lib/

greetings Michel
0
 
mmcwAuthor Commented:
Maybe I try to explain what I do with the output of the form above:

I write the variable $in{'multilingual'} directly to a file.

When I make a line in my program waht prints the output to the screen, the result is: english dutch french german

It looks like there are space between each option!!

But when I try to use the file where I wrote the $in{'multilingual'} variable to and try to split each option by space,

Something like this:
@r_options = split(/ /,$row[3]);
Where $row[3] is the place where I wrote the variable $in{'multilingual'} to.

it will not work!!!
$r_option[0] = english dutch french german
and
$r_option[1] =
$r_option[2] =
$r_option[3] =

Last option are empty!!

Hope you can help me!!
0
 
hualianCommented:
This Script is test work ok.

$raw[3]="english dutch french german";
@r_options = split(/ /,$raw[3]);
print "
       $r_options[0] =
       $r_options[1] =
       $r_options[2] =
       $r_options[3] =";

maybe you need do it again.
@r_options = split(/ /,$raw[3]);

@r_option=split(/ /,$r_options[0]);

or

use

@r_options = split(/\0/,$raw[3]);
0
 
mmcwAuthor Commented:
The \0 option did work
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now