473,395 Members | 1,537 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,395 software developers and data experts.

mutiple selection view in select box

hi,
i am new to this forum.i need help for view a mutiple selected value from database.....that is already selected value display..

my code.....[php]
$jobcount=count($vinloc);
print" <td><select name=\"selintloc[]\" size=\"3\" width=\"25\" class=\"widthed\" multiple=\"multiple\" tabindex=\"5\">";
for($c=0;$c<$jobcount;$c++)
{
print"<option value=\"$vinloc[$c]\" selected>$vinloc[$c]</option>";

print"<option value=\"Bangalore\" ".("Bangalore"==$vinloc [$c]?"selected=on":"")." >Bangalore</option>";
print"<option value=\"Calcutta\" ".("Calcutta"==$vinloc[$c]?"selected=on":"" ).">Calcutta</option>";
print"<option value=\"chennai \" ".("Chennai"==$vinloc[$c]?"selected=on":"" )." >Chennai</option>";
print"<option value=\"Delhi\" ".("Delhi"==$vinloc[$c]?"selected=on":"" ).">Delhi</option>";
print"<option value=\"Hyderabad\" ".("Hyderabad"==$vinloc[$c]?"selected=on":"").">Hyderabad</option>";
print"<option value=\"Kochi\" ".("Kochi"==$vinloc[$c]?"selected=on":"").">Kochi</option>";
print"<option value=\"Mumbai\" ".("Mumbai"==$vinloc[$c]?"selected=on":"" ).">Mumbai</option>";
}
[/php]
it display twice the all value......
Feb 25 '08 #1
3 1191
harshmaul
490 Expert 256MB
Hi,
Firstly welcome the thescripts :)
Secondly next time please use code tags :(
Thirdly your problem...
You are echoing the options on every iteration of the for loop. You need to re work your logic.
Forthly if you can't work it out, i'm gonna write some code when i get time and you can look at it later.

Thanks :)
Feb 25 '08 #2
harshmaul
490 Expert 256MB
Hi again, heres some badic code, it might need a spot of debugging as i haven't got apache at work, but i think it should give you at least some direction


[PHP]<?php
//Bangalore loop
$strSelected = "";
for($c=0;$c<$jobcount;$c++)
{
$strSelected = ("Bangalore"==$vinloc [$c]?"selected=on":$strSelected);
}?>
<option value="Bangalore" <?php echo $strSelected ?>>Bangalore</option>

<?php
//Calcutta Loop
$strSelected = "";
for($c=0;$c<$jobcount;$c++)
{
$strSelected = ("Calcutta"==$vinloc [$c]?"selected=on":$strSelected);
}?>
<option value="Calcutta" <?php echo $strSelected ?>>Calcutta</option>

<?php
//Chennai Loop
$strSelected = "";
for($c=0;$c<$jobcount;$c++)
{
$strSelected = ("Chennai"==$vinloc [$c]?"selected=on":$strSelected);
}?>
<option value="Chennai" <?php echo $strSelected ?>>Chennai</option>

<?php
//Chennai Loop
$strSelected = "";
for($c=0;$c<$jobcount;$c++)
{
$strSelected = ("Delhi"==$vinloc [$c]?"selected=on":$strSelected);
}?>
<option value="Delhi" <?php echo $strSelected ?>>Delhi</option>[/PHP]
Feb 25 '08 #3
hi harshmaul


it great..Thank you very much.....
Feb 25 '08 #4

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

Similar topics

1
by: Blnukem | last post by:
Hi All I need some assistance I have a perl script the dynamically creates several numeric drop boxes on a webppage the amount off boxes and numbers in those drop boxes varies depending on the...
7
by: damjanu | last post by:
Hi All; I need little help. I have a datasheet form. I allow user to do 'filter by selection'. My form contains a column with values. As user changes selections, I want to calculate totals....
0
by: deepak | last post by:
i have set multiple selection property in bith listboxes(html control) to true. i have taken 2 buttons(html control) say Button1,Button2.now i want to add mutiple selected items to another listbox...
2
by: Jason | last post by:
Still working on this HTML Editor control. I have a problem when the user selects some hyperlinks. Sometimes the selection includes other tags. I figured that I could use movestart and moveend...
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
3
by: =?Utf-8?B?bGVzbGllIGVsZHJpZ2U=?= | last post by:
Hi, I am using TAB control with 2 tab pages. First tab page contains a tree view and second also a tree view control. If I select any node of first tree view on the first tab page and then go to...
13
by: shanmugamit | last post by:
hi, i am shanmugam.i am new to this forum.i need mutipe select box validation. Thank you....
2
by: ravitunk | last post by:
hi..i have a datagridview in my windows application using C#......i want to select mutiple cells(by pressing shift key) or select mutiple columns or multiple rows.....if this happens then i should...
7
by: ammweb | last post by:
How would you validate a page that had several drop down menus. When the submit button is submitted, and NO selection has been made? See code below: <html> <head> </head> <body> <table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...
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...

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.