|
Re: populating a list box problem [message #171099 is a reply to message #171096] |
Fri, 24 December 2010 19:25 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 12/24/2010 2:09 PM, richard wrote:
> rather than having a god awful long mess of "options" in the code, I would
> like to populate the listbox by using php.
>
> One short code I found winds up with an error.
>
> Basically what I want is a simple array that holds a list of names.
> A very long list. Over 500.
> Actually, there will be 5 listboxes, with 100 to each box.
>
> The idea being, that when a name is clicked on, which resides in one
> division, the corresponding information will show up beside it in another
> division.
>
> Anyone have a site I can look at for help?
> Googling just brings up tons of forums and sites that really don't discuss
> what I need.
>
>
The populating of a listbox is pretty easy - just loop through the array
and echo the appropriate data, i.e.
foreach ($myArray as $myItem)
echo "<option value='$myItem'>$myItem</option>\n";
Of course, if you have a unique identifier for each item, that would go
in the value field instead of the item itself - but it gets the point
across.
If you want to display something based on the selection, you'll need a
client side language such as javascript; the best way to do it would be
to use AJAX to fetch the data from the server. See comp.lang.javascript
for more information on javascript and AJAX.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: populating a list box problem [message #171101 is a reply to message #171096] |
Fri, 24 December 2010 19:31 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 24/12/10 19:09, richard wrote:
> rather than having a god awful long mess of "options" in the code, I would
> like to populate the listbox by using php.
Something like this maybe
echo "<select name=\"pulldown1\">\n";
$i = count($options);
while ($i --) echo "<option value=\"$i\">{$options[$i]}</option>\n";
echo "</select>\n";
Not really sure what you're describing in the rest of your post though.
Rgds
Denis McMahon
|
|
|
Re: populating a list box problem [message #171102 is a reply to message #171099] |
Fri, 24 December 2010 19:31 |
|
richard
Messages: 213 Registered: June 2013
Karma: 0
|
Senior Member |
|
|
On Fri, 24 Dec 2010 14:25:27 -0500, Jerry Stuckle wrote:
> On 12/24/2010 2:09 PM, richard wrote:
>> rather than having a god awful long mess of "options" in the code, I would
>> like to populate the listbox by using php.
>>
>> One short code I found winds up with an error.
>>
>> Basically what I want is a simple array that holds a list of names.
>> A very long list. Over 500.
>> Actually, there will be 5 listboxes, with 100 to each box.
>>
>> The idea being, that when a name is clicked on, which resides in one
>> division, the corresponding information will show up beside it in another
>> division.
>>
>> Anyone have a site I can look at for help?
>> Googling just brings up tons of forums and sites that really don't discuss
>> what I need.
>>
>>
>
> The populating of a listbox is pretty easy - just loop through the array
> and echo the appropriate data, i.e.
>
> foreach ($myArray as $myItem)
> echo "<option value='$myItem'>$myItem</option>\n";
>
> Of course, if you have a unique identifier for each item, that would go
> in the value field instead of the item itself - but it gets the point
> across.
>
> If you want to display something based on the selection, you'll need a
> client side language such as javascript; the best way to do it would be
> to use AJAX to fetch the data from the server. See comp.lang.javascript
> for more information on javascript and AJAX.
thanks jerry. your approach seems rather straightforward enough even for me
to understand. I hope.
|
|
|
Re: populating a list box problem [message #171103 is a reply to message #171099] |
Fri, 24 December 2010 19:36 |
|
richard
Messages: 213 Registered: June 2013
Karma: 0
|
Senior Member |
|
|
On Fri, 24 Dec 2010 14:25:27 -0500, Jerry Stuckle wrote:
> On 12/24/2010 2:09 PM, richard wrote:
>> rather than having a god awful long mess of "options" in the code, I would
>> like to populate the listbox by using php.
>>
>> One short code I found winds up with an error.
>>
>> Basically what I want is a simple array that holds a list of names.
>> A very long list. Over 500.
>> Actually, there will be 5 listboxes, with 100 to each box.
>>
>> The idea being, that when a name is clicked on, which resides in one
>> division, the corresponding information will show up beside it in another
>> division.
>>
>> Anyone have a site I can look at for help?
>> Googling just brings up tons of forums and sites that really don't discuss
>> what I need.
>>
>>
>
> The populating of a listbox is pretty easy - just loop through the array
> and echo the appropriate data, i.e.
>
> foreach ($myArray as $myItem)
> echo "<option value='$myItem'>$myItem</option>\n";
>
> Of course, if you have a unique identifier for each item, that would go
> in the value field instead of the item itself - but it gets the point
> across.
>
> If you want to display something based on the selection, you'll need a
> client side language such as javascript; the best way to do it would be
> to use AJAX to fetch the data from the server. See comp.lang.javascript
> for more information on javascript and AJAX.
So if I wanted to use a number after value= then I would use something like
value='number' ??
|
|
|
|
Re: populating a list box problem [message #171106 is a reply to message #171103] |
Fri, 24 December 2010 21:10 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 12/24/2010 2:36 PM, richard wrote:
> On Fri, 24 Dec 2010 14:25:27 -0500, Jerry Stuckle wrote:
>
>> On 12/24/2010 2:09 PM, richard wrote:
>>> rather than having a god awful long mess of "options" in the code, I would
>>> like to populate the listbox by using php.
>>>
>>> One short code I found winds up with an error.
>>>
>>> Basically what I want is a simple array that holds a list of names.
>>> A very long list. Over 500.
>>> Actually, there will be 5 listboxes, with 100 to each box.
>>>
>>> The idea being, that when a name is clicked on, which resides in one
>>> division, the corresponding information will show up beside it in another
>>> division.
>>>
>>> Anyone have a site I can look at for help?
>>> Googling just brings up tons of forums and sites that really don't discuss
>>> what I need.
>>>
>>>
>>
>> The populating of a listbox is pretty easy - just loop through the array
>> and echo the appropriate data, i.e.
>>
>> foreach ($myArray as $myItem)
>> echo "<option value='$myItem'>$myItem</option>\n";
>>
>> Of course, if you have a unique identifier for each item, that would go
>> in the value field instead of the item itself - but it gets the point
>> across.
>>
>> If you want to display something based on the selection, you'll need a
>> client side language such as javascript; the best way to do it would be
>> to use AJAX to fetch the data from the server. See comp.lang.javascript
>> for more information on javascript and AJAX.
>
> So if I wanted to use a number after value= then I would use something like
> value='number' ??
It depends on where you get the number from. You can't have just any
number - you need to associate that number to the value itself. For
instance, if the data were stored in a database, the value would often
be the unique id of that row.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: populating a list box problem [message #171117 is a reply to message #171101] |
Sat, 25 December 2010 11:27 |
Peter
Messages: 15 Registered: March 2003
Karma: 0
|
Junior Member |
|
|
In article <4d14f5a0$0$31600$bed64819(at)gradwell(dot)net>,
denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
> On 24/12/10 19:09, richard wrote:
>> rather than having a god awful long mess of "options" in the code, I would
>> like to populate the listbox by using php.
>
> Something like this maybe
>
> echo "<select name=\"pulldown1\">\n";
> $i = count($options);
> while ($i --) echo "<option value=\"$i\">{$options[$i]}</option>\n";
> echo "</select>\n";
>
> Not really sure what you're describing in the rest of your post though.
>
> Rgds
>
> Denis McMahon
>
Just quickly, I noticed both you and Jerry included \n (newline
character) in your output. Is there a specific reason for adding that?
Would have thought it was completely unnecessary.
--
Pete Ives
Remove All_stRESS before sending me an email
|
|
|
Re: populating a list box problem [message #171118 is a reply to message #171117] |
Sat, 25 December 2010 11:42 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 25/12/10 11:27, Peter wrote:
> Just quickly, I noticed both you and Jerry included \n (newline
> character) in your output. Is there a specific reason for adding that?
> Would have thought it was completely unnecessary.
Makes it a lot easier to read when viewing the source of the generated
webpage to see why it doesn't do what you want.
In this case, the OP is talking about 100 options in each list ....
If you were trying to debug that webpage, would you prefer:
<select name="somename" id="someid">
<option value="somevalue">sometext</option>
<option value="somevalue">sometext</option>
... repeat 98 more times 1 per line
</select>
or:
<select name="somename" id="someid"><option
value="somevalue">sometext</option><option
value="somevalue">sometext</option> .. repeat 98 more times on the same
line </select>
Rgds
Denis McMahon
|
|
|
Re: populating a list box problem [message #171119 is a reply to message #171117] |
Sat, 25 December 2010 13:42 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 12/25/2010 6:27 AM, Peter wrote:
> In article<4d14f5a0$0$31600$bed64819(at)gradwell(dot)net>,
> denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
>> On 24/12/10 19:09, richard wrote:
>>> rather than having a god awful long mess of "options" in the code, I would
>>> like to populate the listbox by using php.
>>
>> Something like this maybe
>>
>> echo "<select name=\"pulldown1\">\n";
>> $i = count($options);
>> while ($i --) echo "<option value=\"$i\">{$options[$i]}</option>\n";
>> echo "</select>\n";
>>
>> Not really sure what you're describing in the rest of your post though.
>>
>> Rgds
>>
>> Denis McMahon
>>
>
> Just quickly, I noticed both you and Jerry included \n (newline
> character) in your output. Is there a specific reason for adding that?
> Would have thought it was completely unnecessary.
>
Unnecessary - but practical. Makes the source more readable when you
need to view it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: populating a list box problem [message #171121 is a reply to message #171119] |
Sat, 25 December 2010 20:51 |
Norman Peelman
Messages: 126 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
Jerry Stuckle wrote:
> On 12/25/2010 6:27 AM, Peter wrote:
>> In article<4d14f5a0$0$31600$bed64819(at)gradwell(dot)net>,
>> denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
>>> On 24/12/10 19:09, richard wrote:
>>>> rather than having a god awful long mess of "options" in the code, I
>>>> would
>>>> like to populate the listbox by using php.
>>>
>>> Something like this maybe
>>>
>>> echo "<select name=\"pulldown1\">\n";
>>> $i = count($options);
>>> while ($i --) echo "<option value=\"$i\">{$options[$i]}</option>\n";
>>> echo "</select>\n";
>>>
>>> Not really sure what you're describing in the rest of your post though.
>>>
>>> Rgds
>>>
>>> Denis McMahon
>>>
>>
>> Just quickly, I noticed both you and Jerry included \n (newline
>> character) in your output. Is there a specific reason for adding that?
>> Would have thought it was completely unnecessary.
>>
>
> Unnecessary - but practical. Makes the source more readable when you
> need to view it.
>
I would just like to add that you should pick one way of using
quotes. Single quotes are just fine in HTML. The example below is much
easier (readable) on the eyes in my opinion. Just keep in mind that \n
only works inside double quotes.
echo "<select name='pulldown1'>\n";
$i = count($options);
while ($i--) echo "<option value='$i'>{$options[$i]}</option>\n";
echo "</select>\n";
--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
|
|
|
Re: populating a list box problem [message #175793 is a reply to message #171096] |
Wed, 26 October 2011 09:29 |
bcabangana
Messages: 1 Registered: October 2011
Karma: 0
|
Junior Member |
|
|
Hi
I am having a problem on populating a valuelistBox in gwt
here is the code
private ValueListBox <String> getValueListBox() {
if (valueListBox == null) {
valueListBox = new ValueListBox(IntegerRenderer.instance());
loadMenu.add("...Please Select...");
loadMenu.add("Claimant Appeals");
loadMenu.add("Legal Summons");
loadMenu.add("New Claims");
loadMenu.add("Potential Claims");
valueListBox.setValue(loadMenu.get(0));
valueListBox.setAcceptableValues(loadMenu);
The problem is on the IntegerRender line..I am new to this i have used an arraylist (loadMenu) to populate values.....
please help..i am using the mvp structure
Thanks in advanced
|
|
|
Re: populating a list box problem [message #175795 is a reply to message #175793] |
Wed, 26 October 2011 11:17 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 10/26/2011 5:29 AM, bcabangana(at)gmail(dot)com wrote:
> Hi
>
> I am having a problem on populating a valuelistBox in gwt
>
"I am having a problem" is not very descriptive.
> here is the code
> private ValueListBox<String> getValueListBox() {
> if (valueListBox == null) {
> valueListBox = new ValueListBox(IntegerRenderer.instance());
> loadMenu.add("...Please Select...");
> loadMenu.add("Claimant Appeals");
> loadMenu.add("Legal Summons");
> loadMenu.add("New Claims");
> loadMenu.add("Potential Claims");
> valueListBox.setValue(loadMenu.get(0));
> valueListBox.setAcceptableValues(loadMenu);
>
> The problem is on the IntegerRender line..I am new to this i have used an arraylist (loadMenu) to populate values.....
> please help..i am using the mvp structure
>
> Thanks in advanced
>
What is your problem?
Did you ask GWT support? They know their code better than anyone else.
When having trouble with a product, generally the first place to ask
for help is in that product's support structure.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: populating a list box problem [message #175796 is a reply to message #175793] |
Wed, 26 October 2011 22:28 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
bcabangana(at)gmail(dot)com wrote:
> I am having a problem on populating a valuelistBox in gwt
>
> here is the code
> private ValueListBox <String> getValueListBox() {
> if (valueListBox == null) {
> valueListBox = new ValueListBox(IntegerRenderer.instance());
> loadMenu.add("...Please Select...");
> loadMenu.add("Claimant Appeals");
> loadMenu.add("Legal Summons");
> loadMenu.add("New Claims");
> loadMenu.add("Potential Claims");
> valueListBox.setValue(loadMenu.get(0));
> valueListBox.setAcceptableValues(loadMenu);
>
> The problem is on the IntegerRender line..I am new to this i have used an
> arraylist (loadMenu) to populate values..... please help..i am using the
> mvp structure
Admittedly I do not know much about GWT. But I do know that is *Java*-based,
that the code above looks like *Java* code, that it does not look anything
like (good) PHP code, and that by contrast this is a newsgroup where *PHP*
is on-topic.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
|
|
|