Jump to content

Recommended Posts

I have this code and i understand it all appart from the

<option value = '' <? if ( $_SESSION['area'] == '' ){echo 'selected';}?>>Area</option>

 

echo 'selected'

 

What is that doing please.

 

Well, listening to the logic:

 

If the session variable 'area' contains nothing (empty string), than it will return the string 'selected'. So it will display: "Selected>Area" or similar into the html, the tag would make it selected.

Link to comment
https://forums.phpfreaks.com/topic/187681-whats-echo-selected/#findComment-990822
Share on other sites

selected="selected" is the proper way to do that.. But what it does is if that is contained in any given option that option is selected by default.

 

example

<select name="example">
<option value="var1">Option One</option>
<option value="var2">Option Two</option>
<option value="var3" selected="selected">Option Three</option>
<option value="var4">Option Four</option>

 

in the example, the option "Option Three" will be selected by default.

Link to comment
https://forums.phpfreaks.com/topic/187681-whats-echo-selected/#findComment-990850
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.