PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 4th, 2002, 12:49 AM
bakul bakul is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Banas Dairy,Palanpur
Posts: 0 bakul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to bakul
Question How to store mulitiselected value in php

Dear Sir,

I had made web application using php and postgresql. I want to use
mulitple selection box. Please send me how can i know where user select
mulitple value and submit form. Because I have to store all selected
values.

I had asp code which is pasted below but for php what is coding i
donot
know plese help me.
mail at : URL, URL

Listing 35.3 multi.htm--One of the Fields of This Form May
Have Multiple Values
<FORM METHOD="GET" ACTION="doMulti.asp">
<BR>First name: <INPUT TYPE="text" NAME="first">
<BR>Last name: <INPUT TYPE="text" NAME="last">
<BR>Occupation (select all that apply):
<SELECT NAME="Occupation" MULTIPLE SIZE=5>
<OPTION Executive>Executive
<OPTION Professional>Professional
<OPTION Engineer>Engineer
<OPTION Skilled>Skilled Labor
<OPTION Clerical>Clerical
</SELECT>
<BR><INPUT TYPE="submit" VALUE="Enter">
</FORM>
Listing 35.4 doMulti.asp--Use This ASP Script to Read the
Values from "Occupation"
<%@ Language = VBScript %>
<HTML>
<HEAD><TITLE>Welcome</TITLE></HEAD>
<BODY>
<H1>Welcome</H1>
<P>Hello, <%= Request.QueryString("first") %>
<%= Request.QueryString("last") %> </P>
<P>Welcome to my site.</P>
<P>
<% theNumberOfOccupations =
Request.QueryString("Occupation").Count %>
<% if theNumberOfOccupations = 0 %>
You must be unemployed
<% else if theNumberOfOccupations = 1 %>
Your occupation is
<% Request.QueryString("Occupation")(1) %>
<% else %>
Your occupations are
<% Request.QueryString("Occupation")(1) %>
<% For i = 2 to theNumberOfOccupations - 1 %>
,<% Request.QueryString("Occupation")(i) %>
<% Next %>
and <%
Request.QueryString("Occupation")(theNumberOfOccupation
s) %>
<END IF>
.</P>
<P><A HREF="next.htm">Next</A></P>
</BODY>
</HTML>


waiting for favourable reply, Bye...
regards, bakul

Reply With Quote
  #2  
Old June 4th, 2002, 04:11 AM
zubi zubi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 zubi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
<SELECT NAME="Occupation[]" MULTIPLE SIZE=5>

Reply With Quote
  #3  
Old June 4th, 2002, 04:14 AM
sunnychan's Avatar
sunnychan sunnychan is offline
a lazy guy
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Hong Kong
Posts: 99 sunnychan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Here is a work around method

use javascript to store the selected values into a hidden variable before submit.

eg.
Code:
<input type="hidden" name="FORM_SELECTED_VALUE">

<script>
function sumup(mylist)
{
  var selected_value = "";
  for (var i=0; i < mylist.options.length; i++)
  {
        var o = mylist.options[i];
        if (o.selected)
        {
             selected_value += "x" + o.value;
        }
  }
  document.myform.FORM_SELECTED_VALUE = selected_value;
}
</script>



PHP Code:
// parse the selected value
$selectedValueArr explode("x"$FORM_SELECTED_VALUE);

// print the result
print_r($selectedValueArr);
...
...
... 

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > How to store mulitiselected value in php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
Stay green...Green IT