Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Perl CGI and scrolling_list

Posted on 1997-07-25
9
Medium Priority
?
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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
 
LVL 5

Accepted Solution

by:
julio011597 earned 150 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Six Sigma Control Plans

660 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