473,569 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting selected item of drop down box

59 New Member
Hi,

How can I get the selected item of the drop down box into a php variable in the same page. The options in drop down box are A,B and C and the code is here

Expand|Select|Wrap|Line Numbers
  1. <select>
  2.   <option value="Item 1">A</option>
  3.   <option value="Item 2">B2</option>
  4.   <option value="Item 3">C</option>
  5. </select>
When the user selects an option from the drop down box, I need that value in the php variable in the same page. And I don't need the submit button, as soon as the user selects item from drop down box the selected item should be in php variable. And I want to do this without using javascript's onchange function. Can I do this only using php.
Does anybody has some idea about this. Please help me.

With regards
Mar 18 '08 #1
1 2210
myth0s
32 New Member
Hi,

How can I get the selected item of the drop down box into a php variable in the same page. The options in drop down box are A,B and C and the code is here

Expand|Select|Wrap|Line Numbers
  1. <select>
  2.   <option value="Item 1">A</option>
  3.   <option value="Item 2">B2</option>
  4.   <option value="Item 3">C</option>
  5. </select>
When the user selects an option from the drop down box, I need that value in the php variable in the same page. And I don't need the submit button, as soon as the user selects item from drop down box the selected item should be in php variable. And I want to do this without using javascript's onchange function. Can I do this only using php.
Does anybody has some idea about this. Please help me.

With regards
PHP is executed before the page loads (Hypertext Preprocessor). It means that PHP execution is completed before the user can even see the select box.

Doing what you want would require refreshing the page everytime the user select an item (re-execute the PHP so your code can know what was selected) or using an iframe or using... javascript.

HTH.
Mar 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2456
by: Serge Myrand | last post by:
Hi, I cannot get the selected option to be POSTed (it does not appear in the QueryString when using GET neither) I construct the drop down list from an array, I select an element in the list, I POST using a submit button. When I use Request.Form("NAME") it's always empty. Is the selected item is Posted? How to retreive it?
4
6290
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by the choice from the drop down box. Something like: <form name="populatefrm" id="contactfrm" method="post"
4
37453
by: charliewest | last post by:
I need to set the selected drop down list value at run time. I am aware of the method "SelectIndex" however this works only if you know the precise location of the value within the ListItem collection. Otherwise, what is the recommended approach? I have managed to set the appropriate value using the following loop: for (int i = 1; i <...
0
1098
by: =?Utf-8?B?TmFjaA==?= | last post by:
It works on the first selection when I want to get a different selection I get InvalidArgument=Value of '0' is not valid for 'index'. Parameter name: index The Following is the code Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
2
4122
by: jimmyg123 | last post by:
Hi, I have used a loop so there are a number of quantity drop down menu's designed for a shopping cart style website, with $i being the loop counter and qty being the name of the drop down menu so I have used (ignore the onChange function) <select id='qty{$i}' onChange='findTotal($price,$i)'> <option value='0'>0</option> <option...
5
3943
by: tsunet | last post by:
HI.. I wana display that, initially in a one drop down control there will be some values. Initially, 2nd drop down control will be disabled. if user selects 1st drop down then and then only value which user has selected in 1st drop down control will be displayed in 2nd drop down control. The values can be selected randomly. Plz tell me.
1
1643
by: tsunethere | last post by:
hi .. I have 2 drop-down boxes. at first when web page will get load value this drop-down value will be"---" in this fashion. and 2nd drop-down will be disabled. unless and until user selects item from 1st drop-down 2nd will be disabled. As soon as user enter value in 1st drop-down, 2nd will get enabled and user can select value in 2nd...
2
2882
by: driplet | last post by:
Hi guys: I am using Borland C++ Builder to make a window application. I need to use a list box to display the items I selected. Besides, I need to chang the order of the selected items in the box. Could any body please give me a clue how I can do this? Thanks in advance! Doug
3
1302
by: Salochin | last post by:
Hi all, I have a data base that works quiet well ((considering I built it lol)) its a simple relationship data base that I can fill in, Info like staff details, IT assets, phone extension etc... its basicly an IT itinary so when a problem arrises we have all info at hand for our IT service desk.. now Im neededing to have this data base in...
0
7695
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...
0
7612
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...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
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...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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...
1
5509
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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

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.