5 Replies - 2114 Views - Last Post: 18 June 2013 - 11:21 AM Rate Topic: -----

#1 behonest   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 05-June 13

set select option default value empty

Posted 15 June 2013 - 02:06 AM

i have select option control i want set default value empty how can i set it?

<?php
      for($i=0; $i<sizeof($row); $i++){
	echo '<option selected value ="'.$row[$i]['empID'].'">' . 
		$row[$i]['professionalID'] . '-' . $row[$i]['fullname'] .'</option>';
			   }
           ?>

This post has been edited by Dormilich: 15 June 2013 - 03:05 AM
Reason for edit:: please use [CODE] [/CODE] tags when posting code


Is This A Good Question/Topic? 0
  • +

Replies To: set select option default value empty

#2 Dormilich   User is online

  • 痛覚残留
  • member icon

Reputation: 4201
  • View blog
  • Posts: 13,273
  • Joined: 08-June 10

Re: set select option default value empty

Posted 15 June 2013 - 03:06 AM

what do you mean by "set default value empty" ? at least you shouldn’t mark every option as selected, though.
Was This Post Helpful? 0
  • +
  • -

#3 behonest   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 05-June 13

Re: set select option default value empty

Posted 17 June 2013 - 10:49 PM

i want to set ever time page loaded i want to set option value empty.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich   User is online

  • 痛覚残留
  • member icon

Reputation: 4201
  • View blog
  • Posts: 13,273
  • Joined: 08-June 10

Re: set select option default value empty

Posted 17 June 2013 - 10:51 PM

that doesn’t tell me anything.
Was This Post Helpful? 0
  • +
  • -

#5 Duckington   User is offline

  • D.I.C Addict

Reputation: 172
  • View blog
  • Posts: 615
  • Joined: 12-October 09

Re: set select option default value empty

Posted 18 June 2013 - 11:05 AM

Just put another option tag with an empty value before you do the loop.
Was This Post Helpful? 2
  • +
  • -

#6 laytonsdad   User is offline

  • Let it rip!
  • member icon

Reputation: 466
  • View blog
  • Posts: 1,992
  • Joined: 30-April 10

Re: set select option default value empty

Posted 18 June 2013 - 11:21 AM

Add an empty option.

<?php
     print "<option selected value="">Make a selection</option>";
      for($i=0; $i<sizeof($row); $i++){
	echo '<option value ="'.$row[$i]['empID'].'">' . 
		$row[$i]['professionalID'] . '-' . $row[$i]['fullname'] .'</option>';
			   }
           ?>



Sorry for the edits my computer keeps posting before I'm done.

This post has been edited by laytonsdad: 18 June 2013 - 11:24 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1