By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

adding items to a list or menu

P: n/a
Not sure if it is a php question but since i am working in php here it is.

Ho can i add items to (the item label=visual text and the value=index
number) a list object on a website.

I am having a list with 4 items and i would like to add the text from a
textfield (textfield1.value) to the list object so it will hold 5 items.

thanks for any suggestions

Roy
The Netherlands

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"R.G. Vervoort" <ro**********@royvervoort.nl> wrote in message
news:40*********************@news.xs4all.nl...
Not sure if it is a php question but since i am working in php here it is.

Ho can i add items to (the item label=visual text and the value=index
number) a list object on a website.

I am having a list with 4 items and i would like to add the text from a
textfield (textfield1.value) to the list object so it will hold 5 items.

thanks for any suggestions

Roy
The Netherlands


You're right. That's a JavaScript question. comp.lang.javascript is
thataway. Sorry.

Oh, and don't cross-post.

Garp
Jul 17 '05 #2

P: n/a
"R.G. Vervoort" <ro**********@royvervoort.nl> wrote in message
news:40*********************@news.xs4all.nl...
Not sure if it is a php question but since i am working in php here it is.

Ho can i add items to (the item label=visual text and the value=index
number) a list object on a website.

I am having a list with 4 items and i would like to add the text from a
textfield (textfield1.value) to the list object so it will hold 5 items.

thanks for any suggestions


Just to piss off the other guy, here's the JS code for adding an item

var o = document.createElement('OPTION');
o.innerText = textfield1.value;
o.value = 'Something';
document.getElementById('listbox_id').appendChild( o);

HTML:

<select id="listbox_id">
<option>Hello</option>
...
</select>

Jul 17 '05 #3

P: n/a
"R.G. Vervoort" <ro**********@royvervoort.nl> wrote in message news:<40*********************@news.xs4all.nl>...
Not sure if it is a php question but since i am working in php here it is.

Ho can i add items to (the item label=visual text and the value=index
number) a list object on a website.

I am having a list with 4 items and i would like to add the text from a
textfield (textfield1.value) to the list object so it will hold 5 items.

thanks for any suggestions

Roy
The Netherlands


PHP is server side, it looks like you want to send items to a client
side app (javascript?) you could do something like this:

--->Snip!

<?php

$array = array('item1', 'item2', 'item3', 'item4'); //I use an array
here for simplicity, you could do the same with a dB query or the like

echo "<html>\n<head></head><!--javascript-->"; //Not a javascript guy,
but you get the point

foreach($array as $key=>$item) {
echo "\n textdata.item$key=$item";
}

?>
<body> etc.....

<---

Not sure how javascript looks (started working with it in last 2 days)
but you can change that echo statement to what it should be in
javascript

Cheers!

Robert
Jul 17 '05 #4

P: n/a

"Chung Leong" <ch***********@hotmail.com> wrote in message
news:1L********************@comcast.com...
"R.G. Vervoort" <ro**********@royvervoort.nl> wrote in message
news:40*********************@news.xs4all.nl...
Not sure if it is a php question but since i am working in php here it is.
Ho can i add items to (the item label=visual text and the value=index
number) a list object on a website.

I am having a list with 4 items and i would like to add the text from a
textfield (textfield1.value) to the list object so it will hold 5 items.

thanks for any suggestions


Just to piss off the other guy, here's the JS code for adding an item

var o = document.createElement('OPTION');
o.innerText = textfield1.value;
o.value = 'Something';
document.getElementById('listbox_id').appendChild( o);

HTML:

<select id="listbox_id">
<option>Hello</option>
...
</select>


Heh, if you mean me as "the other guy", I'm happy he got his answer. And
when he asks which lace to cross next in four groups, you can help there too
(and repeat his cross-post again).

Hugs.

Garp
Jul 17 '05 #5

P: n/a
"Garp" <ga***@no7.blueyonder.co.uk> wrote in message
news:%j*********************@news-text.cableinet.net...
Heh, if you mean me as "the other guy", I'm happy he got his answer. And
when he asks which lace to cross next in four groups, you can help there too (and repeat his cross-post again).


Oops. Didn't even check the to line.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.