Select Element

J

John Maag

I am interested in using a Select element but I want to know if there is any
way to specify the width and height of the object.

I realize the width will auto size to the data but would still like to know
if it can be done. Just to be clear what I am trying to do I will paste some
code:

<select name="attribute[]" size=5 multiple>
<option value="perky">Perky</option>
<option value="morose">Morose</option>
<option value="thinking">Thinking</option>
<option value="feeling">Feeling</option>
<option value="thrifty">Thrifty</option>
<option value="prodigal">Prodigal</option>
</select>
 
J

Jukka K. Korpela

Scripsit John Maag:
I am interested in using a Select element but I want to know if there
is any way to specify the width and height of the object.

You can use the CSS properties width and height, e.g.

<select ... style="width: 10em; height: 8em">
 
J

John Maag

Thanks Jukka. I really appreciate it.

Jukka K. Korpela said:
Scripsit John Maag:


You can use the CSS properties width and height, e.g.

<select ... style="width: 10em; height: 8em">
 
J

John Maag

As a followup to this, is there a way to space fields within the list? What
I am trying to do is have information such as name, address, city state and
zip line up in columns. I have been trying to use sprintf as follows but it
seems to ignroe extra spaces between fields.

Here is an example of the sprintf I have been using. I am using the x's to
prove the formatting actually does work if the paddign character is not
space.
$line1 = sprintf ("%' -40s%'x-40s%'x-20s%'x-10s\n", "John Maag", "100 Maple
Ave", "Our Town", "10101");
 
A

Adrienne Boswell

Gazing into my crystal ball I observed "John Maag" <[email protected]> writing
in

Please do not top post.. see response at the bottom of the message.
John Maag said:
I am interested in using a Select element but I want to know if there
is any way to specify the width and height of the object.

I realize the width will auto size to the data but would still like
to know if it can be done. Just to be clear what I am trying to do I
will paste some code:

<select name="attribute[]" size=5 multiple>
<option value="perky">Perky</option>
<option value="morose">Morose</option>
<option value="thinking">Thinking</option>
<option value="feeling">Feeling</option>
<option value="thrifty">Thrifty</option>
<option value="prodigal">Prodigal</option>
</select>

As a followup to this, is there a way to space fields within the list?
What I am trying to do is have information such as name, address, city
state and zip line up in columns. I have been trying to use sprintf as
follows but it seems to ignroe extra spaces between fields.

Here is an example of the sprintf I have been using. I am using the
x's to prove the formatting actually does work if the paddign
character is not space.
$line1 = sprintf ("%' -40s%'x-40s%'x-20s%'x-10s\n", "John Maag", "100
Maple
Ave", "Our Town", "10101");

Use the right tool for the job - a table. If this is for a form, you
could do something like that below:
<form method="post" action="whateverpage">
<table>
<thead>
<tr>
<th>Select</th><th>Name</th><th>Address</th><th>City</th><th>State</th>
<th>Zip</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="radio" name="attribute[]" value="id"></td><td>John Doe
</td><td>123 Any Street</td><td>Any City</td><td>XX</td><td>99999</td>
</tr>
<!-- more choices -->
</tbody>
</table>
<p><input type="submit" value="Submit Choice"></p>
</form>
 
J

Jukka K. Korpela

Scripsit Adrienne Boswell:
Use the right tool for the job - a table.

Agreed; when the data consists of entries of data that consists of
components by the same structure, then it's very much tabular data.
If this is for a form, you
could do something like that below: - -
<td><input type="radio" name="attribute[]" value="id"></td><td>John
Doe </td><td>123 Any Street</td><td>Any
City</td><td>XX</td><td>99999</td>

Especially when you need put an input field and its label to different
cells (and this is probably better here than putting them into same
cell), their logical relationship should be indicated using <label>
markup:

<td><input type="radio" name="attribute[]" value="id"></td><td><label
for="id">John Doe</label></td><td>123 Any Street</td><td>Any
City</td><td>XX</td><td>99999</td>

You'll have to use _different_ id values for each element, but this is
not a problem if the page is programmatically generated. You can e.g.
make the program produce id1, id2, ... - these identifiers need not be
descriptive or mnemonic, since they are not visible to users.

Using <label> markup implies, among other things, that many browsers let
the user click on the label (name) to toggle the radio button setting,
instead of trying to hit the tiny button.
 
A

Adrienne Boswell

Especially when you need put an input field and its label to different
cells (and this is probably better here than putting them into same
cell), their logical relationship should be indicated using <label>
markup:

<td><input type="radio" name="attribute[]" value="id"></td><td><label
for="id">John Doe</label></td><td>123 Any Street</td><td>Any
City</td><td>XX</td><td>99999</td>

Thank you for the tip, Jukka.
 
J

John Maag

Use the right tool for the job - a table. If this is for a form, you

The problem with a table is you have to "page through" the data. Example if
you could only display 20 entries on a page you would have to go through
pages 2and, etc. That is why I preferred a scrollable window.

Is ther a way to scroll and have columnar data?
 
A

Adrienne Boswell

The problem with a table is you have to "page through" the data.
Example if you could only display 20 entries on a page you would have
to go through pages 2and, etc. That is why I preferred a scrollable
window.

Is ther a way to scroll and have columnar data?

Using a drop down would be even worse. Who wants to scroll through 20
entries? Give the user a search function, or don't page at 20 records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,102
Messages
2,570,645
Members
47,243
Latest member
CorrineCad

Latest Threads

Top