View Full Version : How to get values from a dropdownlist using firebug in mozilla firefox

01-04-2011, 02:40 AM

I have this web browser which opens up a website that has a drop down list showing values that the user can select. And when I the firebug to inspect the elements in the page, what shows in the inspection window is this:

<select id="instance2" name="instance2">
<option value="0">All instances</option>
<option value="1">Item0</option>
<option value="2">Item1</option>
<option value="3">Item2</option>
<option value="23">Item22</option>

What I'm supposed to do is to get the values and update them automatically to the database. I'm actually using HtmlUnit to do this project, and I've heard how I can use getElementById() to get the values. But I don't know how to start. I'm a beginner so I might need a lot of help on this matter. Help is kindly appreciated.


01-04-2011, 02:45 AM
Firebug has a console. You output values by using console.log:


Is that what you are asking?

01-04-2011, 02:59 AM
Erm, no, I don't think so. I'm using Netbeans to do this project, and what I have is actually a .java page that sets and gets a HtmlPage. I have "Set request parameters" where a new ArrayList is created:

postRequestSettings.setRequestParameters(new ArrayList());
postRequestSettings.getRequestParameters().add(new NameValuePair("component", "edit"));
postRequestSettings.getRequestParameters().add(new NameValuePair("formids", "unixTime,instance,time,description,message"));
postRequestSettings.getRequestParameters().add(new NameValuePair("page", "Status"));

and then I have this set of codes, which also tallys with what the webpage has, for example, "instance" is the drop down list which the user has to select, "message" and "description" are textboxes where user can input message, and so on.

// Insert instance of message here
postRequestSettings.getRequestParameters().add(new NameValuePair("instance", instance));
// Insert content of message here
postRequestSettings.getRequestParameters().add(new NameValuePair("message", message));
// Insert description of message here
postRequestSettings.getRequestParameters().add(new NameValuePair("description", description));
// Insert time of message here
postRequestSettings.getRequestParameters().add(new NameValuePair("time", time));
// Convert time to unix seconds
postRequestSettings.getRequestParameters().add(new NameValuePair("unixTime", String.valueOf(System.currentTimeMillis() / 1000)));

I'm sorry if I make it sound confusing, because I'm also quite confused. But all I want to do is to get values from the webpage itself, most probably getElementById refers to the option value number.