Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to get values from a dropdownlist using firebug in mozilla firefox

    Hi,

    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:

    Code:
    <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.

    Thanks.

  • #2
    Regular Coder
    Join Date
    Oct 2009
    Posts
    189
    Thanks
    38
    Thanked 3 Times in 3 Posts
    Firebug has a console. You output values by using console.log:

    console.log(document.getElementById("instance2").getElementsByTagName('option'));

    Is that what you are asking?

  • #3
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    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.

    Code:
    // 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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •