473,782 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Php/Javascript problems with multiple select

hello,

I have a PHP/Javascript problem. If I want to make a multiple select
like this one:

$html .= "<td><selec t name='userid' onChange='chang euserinfo()' multiple
size='10'>";
$html .= "<option value=''>Select eer user</option>";
$html .= "<option value='1'>user 1</option>";
$html .= "<option value='2'>user 2</option>";
$html .= "<option value='3'>user 3</option>";
$html .= "<option value='4'>user 4</option>";
$html .= "<option value='5'>user 5</option>";
$html .= "<option value='6'>user 6</option>";
$html .= "</select>";
$html .= "</td>";

I can read this one out with javascript but accourding tot the PHP
manual I have to declare the select as follows to read it out in php:
$html .= "<td><selec t name='userid[]' multiple size='10'>";
and this is something that javascript does not want to swallow :'(

How can i make it so that both javascript and php can access the fields
and do their usefull stuff with it.

HELP MEEEEEEE :)

Greetz,
Ramses

Jul 17 '05 #1
3 3084

"Ramses van Pinxteren" <ra******@NOSPA N.quicknet.nl> wrote in message
news:ef******** *************** ****@news.multi kabel.nl...
hello,

I have a PHP/Javascript problem. If I want to make a multiple select
like this one:

$html .= "<td><selec t name='userid' onChange='chang euserinfo()' multiple
size='10'>";
$html .= "<option value=''>Select eer user</option>";
$html .= "<option value='1'>user 1</option>";
$html .= "<option value='2'>user 2</option>";
$html .= "<option value='3'>user 3</option>";
$html .= "<option value='4'>user 4</option>";
$html .= "<option value='5'>user 5</option>";
$html .= "<option value='6'>user 6</option>";
$html .= "</select>";
$html .= "</td>";

I can read this one out with javascript but accourding tot the PHP
manual I have to declare the select as follows to read it out in php:
$html .= "<td><selec t name='userid[]' multiple size='10'>";
and this is something that javascript does not want to swallow :'(

How can i make it so that both javascript and php can access the fields
and do their usefull stuff with it.

<select id="userid[]" name="userid[]" onchange="chang euserinfo();">

and in the javascript use

FormObject=docu ment.forms['name of form'];
SelectObject=Fo rmObject.elemen ts['userid[]'];

you can then loop through the array SelectObject.op tions[], checking the
'selected' property to see which items have been selected

SelectionCount= 0;
for(n=0;n<Selec tObject.options .length;n++)
{
if(SelectObject .options[n].selected)
{
// option selected
SelectionCount+ +;
}
else
{
// option not selected
}
}

The SelectObject.se lectedindex property only shows the first selected
element.
HELP MEEEEEEE :)

Greetz,
Ramses

Jul 17 '05 #2
Ramses van Pinxteren <ra******@nospa n.quicknet.nl> wrote:
I can read this one out with javascript but accourding tot the PHP
manual I have to declare the select as follows to read it out in php:
$html .= "<td><selec t name='userid[]' multiple size='10'>";
and this is something that javascript does not want to swallow :'(


You are incorrect. Javascript has no problem with elements named like
'userid[]', us the element name in the elements hash.

--

Daniel Tryba

Jul 17 '05 #3
Ramses van Pinxteren <ra******@NOSPA N.quicknet.nl> wrote in message news:<ef******* *************** *****@news.mult ikabel.nl>...
hello,

I have a PHP/Javascript problem. If I want to make a multiple select
like this one:

$html .= "<td><selec t name='userid' onChange='chang euserinfo()' multiple
size='10'>";
$html .= "<option value=''>Select eer user</option>";
$html .= "<option value='1'>user 1</option>";
$html .= "<option value='2'>user 2</option>";
$html .= "<option value='3'>user 3</option>";
$html .= "<option value='4'>user 4</option>";
$html .= "<option value='5'>user 5</option>";
$html .= "<option value='6'>user 6</option>";
$html .= "</select>";
$html .= "</td>";

I can read this one out with javascript but accourding tot the PHP
manual I have to declare the select as follows to read it out in php:
$html .= "<td><selec t name='userid[]' multiple size='10'>";
and this is something that javascript does not want to swallow :'(


Read further. It has an answer.
<http://in2.php.net/manual/en/faq.html.php#fa q.html.select-multiple>

--
"Success = 10% sweat + 90% tears"
Email: rrjanbiah-at-Y!com
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
6558
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the courses to pass the correct option value and then be displayed at the following URL: http://www.dslextreme.com/users/kevinlyons/selectResults.html I am passing countries, products, and courses. The first two display
13
9460
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to intercept the key so that I can do stuff on the server side to make the new window behave correctly? (We have a JSP-based webapp which stores state in the session. Now if two windows access (and modify!) the same session, then madness will result....
3
3927
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is messing up. Problems:
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.