cancel
Showing results for 
Search instead for 
Did you mean: 

Set Selection of htmlb Dropdown

Former Member
0 Kudos

How do i set the htmlb Dropdown selection in the Javascript with the value selected? It getz populated with Model from bean.

<hbj:dropdownListBox

id = "myDdBox1"

disabled = "false"

model = "myBean.model"

selection = "<%=myBean.getSelection()%>"

jsObjectNeeded = "TRUE"

onClientSelect = "Event()">

</hbj:dropdownListBox><br><br>

<script>

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var dropdown = eval(func("myDdBox1"));

what shud i do here??

</script>

Shud i add this also?

var form = document.all(htmlb_formid);

form.submit();

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos
 var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var dropdown = eval(func("myDdBox1"));
//you need to provide the index
dropdown.setSelectedIndex("1");
//or you can set the value
dropdown.setValue("elephant");

Message was edited by: Prakash Singh

Former Member
0 Kudos

But did u notice the htmlb dropdown, itz getting values from the model.

if i set dropdown.setValue(cookie);after reading the cookie value which i set immediately when i select something from dropdown..Itz not showing the value in the dropdown..Howz it possible to stick the value selected al the times in the dropdown?

Former Member
0 Kudos

Then you don't need to javascript. You have to handle everything via server side. Set the selection in your "onProcess" event.

Former Member
0 Kudos

Could you please look @ my par??I guess a simple thing but couldn't actually find it out!

Hep me out prakash!

Former Member
0 Kudos

I tried with server side..Couldn't reslove it.

Can you look into my code..u might suggest something.

Thank you