• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select problem

 
Don Martino
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm retreiving a value from a d/b and want to display correct entry when page is loaded.
If database_type = "GEN", how would I get the GEN entry to display?


<select name="type" onchange=''>
<option value="DIG">DIG</option>
<option value="ENR">ENR</option>
<option value="GEN">GEN</option>
<option value="MUS">MUS</option>
<option value="PRO">PRO</option>
<option value="QUE">QUE</option>
<option value="REF">REF</option>
<option value="RES">RES</option>
<option value="TDD">TDD</option>
</select>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put the selected attribute on the option.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You what it to be selected by default? Than add the selected attribute to the tag.

Eric
[ October 30, 2008: Message edited by: Eric Pascarello ]
 
Don Martino
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't want a specific value displayed as default each time the page loads. I want the value I capture from the d/b record to be displayed, which could be GEN or any of the values listed in the options.

I was just using the "If database_type = "GEN".... as an example, but it will be different each time a new d/b rec is read.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still have no clue what you are trying to do exactly.

Eric
 
Don Martino
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if database_value = "DIG", how do I get the "DIG" entry in select option to display?

Could I create a js function?

function dropdown(){

document.getElementById("type").value = document.getElementById("database_value").value;

}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using JSP, PHP, something else, on the back end?

If so, that's where you'd set the selected option.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic