Solved

Perl CGI and scrolling_list

Posted on 1997-07-25
9
285 Views
Last Modified: 2009-07-29
I have created an array (@desc) which I am loading into a scrolling_list.  The array is built from a file.  THe file contains lines like:  name      desc
                      another      desc  
The problem is that when the list is diplayed, the space in
between the columns disappears.  It is displayed as:
                     name desc
                     another desc
If I print the array to a file, the columns are preserved. Is the scrolling_list automatically removing extra white space?  It leaves ONE space but not more than that?  

Can I preserve my columns?

For now I have dots as a spacer.  name.....desc but I'd rather use tabs.
0
Comment
Question by:wspoulin
  • 5
  • 2
  • 2
9 Comments
 

Author Comment

by:wspoulin
ID: 1205028
Well, I have just reviewed my question and see that my extra
white space has been removed!!!  I guess I know the answer!

Still, I'd like to know if there is a way around it.

For clarification my file looks like:

      name<spaces or tab........> desc
      another name<spaces or tab> desc2

But my display looks like:

      name desc
      another name desc2
0
 
LVL 2

Expert Comment

by:n3mtr
ID: 1205029
What is scrolling_list?  Did you write it yourself or is it part of some package?
Is this displayed on a browser?  Browsers get rid of extra spaces. You could convert to tables(better), or convert to non breaking spaces(&nbsp).

0
 
LVL 2

Expert Comment

by:n3mtr
ID: 1205030
Another thing, if its not displayed on a web browser you could modify scrolling list to not get rid of the extra spaces.
0
 

Author Comment

by:wspoulin
ID: 1205031
scrolling_list is part of CGI.pm. It is displayed in Netscape.

The code is as follows:

$query->scrolling_list(
  -name=>'projects',
  -values=>[@some_names],
  -default=>$selected,
  -size=>15,
  -onChange=>"refresh()");

@some_names has rows consisting of:   name (tabs) desc

When you say convert to &nbsp do you mean to store &nbsp in the array?  I have tried that and it dispalys: "name&nbsp desc"!



 
When you say, "convert to ... (&nbsp)" do you mean in the array?

0
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.

 
LVL 5

Accepted Solution

by:
julio011597 earned 50 total points
ID: 1205032
It is "&nbsp;", you missed last char.
It follows the rules for non-printable chars's symbolic names.

Another *nice* workaround is putting your list inside the pair <PRE>...</PRE>; let tabs stay into the list and try this.

Cheers, julio
0
 

Author Comment

by:wspoulin
ID: 1205033
I have tried everything!  I have put &nbsp; in the file that
fills the array.  
I have put the <PRE> tags on each line:
$format = "<PRE>".$desc."</PRE>; push(@desc,$format);

I have put the <PRE> tags as part of the list:
push(@desc,"<PRE>");
push(@desc,$data);
push(@desc,"</PRE>");

Scrolling list is part of CGI.pm.  
HELP!  I am forced to display my data as "data.....desc" YUK!
0
 

Author Comment

by:wspoulin
ID: 1205034
I have tried everything!  I have put &nbsp; in the file that
fills the array.  
I have put the <PRE> tags on each line:
$format = "<PRE>".$desc."</PRE>; push(@desc,$format);

I have put the <PRE> tags as part of the list:
push(@desc,"<PRE>");
push(@desc,$data);
push(@desc,"</PRE>");

Scrolling list is part of CGI.pm.  
HELP!  I am forced to display my data as "data.....desc" YUK!
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1205035
No, i meant the html looking something like:

<PRE>
<SELECT...>
<OPTION...>
...
</SELECT>
</PRE>

so, in your code, output the 'PRE' tags before and after the list object.

Going back to your question, surrounding the list with <PRE>...</PRE> would allow you to put any spaces or tabs you need and get them preserved when displayed.

Anyway, i cannot guess why the "&nbsp;" didn't work.
As a suggestion, you could try to get rid of the scrolling_list object, and set up the corresponding code yourself (just a matter of a few print()'s): sometimes, working with third parties libraries may cause just headaches!

-julio
0
 

Author Comment

by:wspoulin
ID: 1205036
Well, I give up!  PRE tags do not preserve it either.  I
think you are correct about the third party utils.  Maybe I
need an upgrade.  

But I will just type the code myself for now.

Thanks for the help!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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