Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 27th Oct 2011, 02:09 PM   #1
Active Warrior
 
Join Date: 2010
Posts: 58
Thanks: 2
Thanked 1 Time in 1 Post
Default
SELECTED in drop down
Share on: 
fb share twitter share gplus share more share

Hi guys, i have a drop down code below



<select class="input" name="mod[cpu]">
<option value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
the output are like this
$html .= ($content[cpu] ? '<div class="' . $this->switch_bg() . '"><strong>CPU:</strong> ' . @htmlspecialchars($content[cpu]) . '</div>' : '');



i want after the drop down choosed by user, it will add SELECTED next time they opening the drop down again

i am still dont know how to put the SELECTED there, please help what is the code to add SELECTED, i only have variable mod[cpu] and $content[cpu]


i already tried in bold below, but still not working

<select class="input" name="mod[cpu]" selected="$content[cpu]">
<option value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>




please share your knowledge

I like forum
basketmen is offline  
Unread 27th Oct 2011, 11:43 PM   #2
Active Warrior
War Room Member
 
Join Date: 2011
Posts: 50
Thanks: 0
Thanked 4 Times in 4 Posts
Default
Re: SELECTED in drop down
Share on: 
fb share twitter share gplus share more share

what do u have in $content[cpu]??

any way... selected should be in the option tag and not in the select tag...

<select class="input" name="mod[cpu]">
<option value=""> </option>
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
</select>
shabtay is offline  
Unread 28th Oct 2011, 11:11 PM   #3
HyperActive Warrior
War Room Member
 
Tim Brownlaw's Avatar
 
Join Date: 2009
Location: Berwick, Melbourne, Australia
Posts: 156
Thanks: 5
Thanked 47 Times in 28 Posts
Default
Re: SELECTED in drop down
Share on: 
fb share twitter share gplus share more share

i want after the drop down choosed by user, it will add SELECTED next time they opening the drop down again
This would require either saving the information in a Database and retrieving it on redisplaying the page or using a session.

Either way the option list needs to be generated in say PHP where it inserts the selected field in the appropriate entry so it appears as the chosen field.

Here's a little demo which just demonstrates the use of a form with a select box. It might help you, but it seems you need a little more understanding of what you are currently using in your script...

I've included a PDF with some explanation and the demonstration script.
Hope that helps!
Attached Files
File Type: zip LOMS - Forms - Option Drop Downs -1.zip (107.2 KB, 3 views)

Great Success is built from many little successes!

http://www.timbrownlaw.com - My Wee Part of the World.

http://www.LookingOverMyShoulder.com
Tim Brownlaw is offline  
Closed Thread


Bookmarks

Tags
drop, selected


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 03:39 AM.