473,383 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

getting selected item of drop down box

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 2198
myth0s
32
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
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,...
4
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...
4
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...
0
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...
2
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...
5
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...
1
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...
2
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....
3
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......
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.