473,400 Members | 2,163 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,400 software developers and data experts.

combo box selected value problem

I have a one combo box which display values from a table. But onchange i want the selected value in other text box.

[PHP]<?
echo "<select name='selectpg'>\n";
echo "<option value='Select Group' selected>Select Group</option>";
$query = "SELECT t.gname FROM group AS t ORDER BY t.gname ASC";
$res = @mysql_query($query);
while($row = mysql_fetch_array($res))
{
printf("<option value=\"$row[gname]\">$row[gname]</option>\n");
}
echo "</select>";
?>[/PHP]

Any body have idea about this, plz let me know

Thanks & Regards,
Praveen
Jan 9 '08 #1
1 3898
nathj
938 Expert 512MB
I have a one combo box which display values from a table. But onchange i want the selected value in other text box.

[PHP]<?
echo "<select name='selectpg'>\n";
echo "<option value='Select Group' selected>Select Group</option>";
$query = "SELECT t.gname FROM group AS t ORDER BY t.gname ASC";
$res = @mysql_query($query);
while($row = mysql_fetch_array($res))
{
printf("<option value=\"$row[gname]\">$row[gname]</option>\n");
}
echo "</select>";
?>[/PHP]

Any body have idea about this, plz let me know

Thanks & Regards,
Praveen
Hi Praveen,

I would do this with a simple javascript function called by the Select onchange event.

[html]
<select id="selectpg" onchcnage="poplateText('selectpg', 'textDisplay');"
[/html]
NOTE: 'textDisplay' is the ID of the input text you control where the value should display. the rest of your code should be fine, this is just to illustrate where the onchange call goes.

The javascript would look like:
[code]
function populateText(pcSourceID, pcTargetID)
{
// get the source value
lcSourceValue = document.getElementById(pcSourceID).value ;
//set the target value
document.getElementById(pcTargetID).value = lcSourceValue ;
}

This simple function should do the trick.

Cheers
nathj
Jan 10 '08 #2

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

Similar topics

1
by: Daniel Hill | last post by:
OK, I have very, VERY basic background knowledge of VB6 and have now upgraded to VB.NET and now I'm struggling to bring up the forms I want. What I am looking to do is to have a click a command...
4
by: Heather | last post by:
Hi I am desparately looking for advice in relation to storing the results after selecting items from two combo boxes on a Referral form. The first combo box 'ctl Type' displays a full list of...
1
by: Daniel | last post by:
Hi there, I've been having a problem with binding to a combo box. I'm binding to a third party dataset table view. When on the selected tab page and you click a certain tree node it will fire a...
4
by: Mark L. Breen | last post by:
Hello Guys and Galls, I use combos on my forms. The code to initialise the combos is as follows Dim dsPIDTypes As DataSet dsPIDTypes = PartDB.GetPIDTypes ' Returns a dataset object...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
8
by: salad | last post by:
I was wondering how you handle active/inactive elements in a combo box. Let's say you have a combo box to select an employee. Joe Blow has been selected for many record however Joe has left the...
1
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this...
4
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
6
by: =?Utf-8?B?amVmZmVyeQ==?= | last post by:
i need help with a combo box and this same code works on my first tab with a combo box. The error or problem i have is this code causes an index out of range error when i run it on my second combo...
0
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable,...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.