facebook

Getting Values From Combo Box

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #343431 Reply

    mthaney4
    Participant

    Hello all,

    I am having some trouble with some javascript. I have followed another tutorial on here and manipulated the code as I needed, but I am having trouble.

    Here is the code

    var result = "";
      //PSL Employee
      result += "PSL Member: " + $("#m1-Block-b1-cmbTeamMemberBlock").val() + "\n";

    I want to pipe in the selected value from the combobox into a text box. Everything is working when it comes to getting text from another text box, but I do not know how to get selected values from the combo box.

    The app is an invoicing app, and as the user clicks through the questions and answers them, they will come to the end page, and click a button to get all of the info entered in the steps before to pipe into a text box to email as a form. It is working with all of the text boxes fine.

    Hope this makes sense.

    #343433

    @mthaney4,

    Is your screen named Block-b1?? If yes, please try replacing the dash “-” for an underscore “_”.

    result += “PSL Member: ” + $(“#m1-Block_b1-cmbTeamMemberBlock”).val() + “\n”;

    #343436

    mthaney4
    Participant

    Here is the layout

    FrontPage.mobi
    Block-b1.mobi
    Block-b2.mobi

    Block-b10.mobi

    All pages feed into a text box on Block-b10.mobi. The combo box I need to feed into the text box is on Block-b1.mobi and its element id is cmbTeamMemberBlock. Make sense? Thanks for your quick respose and for trying to help me out.

    #343437

    mthaney4
    Participant

    Here is the code to feed into the text box on Block-b10.mobi Everything works except for the //PSL Employee code

    var result = "";
      //PSL Employee
      result += "PSL Member: " + $("#m1-Block-b1-cmbTeamMemberBlock").val() + "\n";
      
      //title
      result = "BLOCK " + "\n";
      
      //get First Name Block
      result += "First Name: " + $("#m1-Block-b1-txtFirstNameBlock").val() + "\n";
     
      //get Last Name Block
      result += "Last Name: " + $("#m1-Block-b1-txtLastNameBlock").val() + "\n";
    
      //get Address Block
      result += "Address: " + $("#m1-Block-b1-txtAddressBlock").val() + "\n";
    
      //get City Block
      result += "City: " + $("#m1-Block-b1-txtCityBlock").val() + "\n";
      
      //get State Block
      result += "State: " + $("#m1-Block-b1-txtStateBlock").val() + "\n";
      
      //get Zip Block
      result += "Zip: " + $("#m1-Block-b1-txtZipBlock").val() + "\n";  
      
      //get Phone Number Block
      result += "Phone Number: " + $("#m1-Block-b1-txtPhoneBlock").val() + "\n";  
    
      //get Email Block
      result += "Email: " + $("#m1-Block-b1-txtEmailBlock").val() + "\n";  
      
      //update BLOCK summary page
      $('[id$=m1-Block-b10-txtResultsBlock]').text(result);
    #343473

    Hi mthaney4,

    When I saw the dash on your screen name I thought it was the problem since I had seen problems with dashes before.

    The thing is that comboboxes are implemented using a hidden <select> tag and show the current value in a div, so in order to get the value of that hidden <select> you have to use next snippet:

    $('select[name="combobox1"]').val()

    In your case it should be:

    $('select[name="cmbTeamMemberBlock"]').val()

    Let me know how it goes.

    #343486

    mthaney4
    Participant

    So, I had tried the code you suggested many times before, but it got me thinking that “PSL Member” was not even showing in the results. So, I switched that line with the top line, and added it as you specified….and it worked. I had even tried

     //PSL Employee
      result += "PSL Member: " + $('select[name="cmbTeamMemberBlock"]:selected').val() + "\n";
      

    but this didn’t work either. So it seems like something in the top line was interfering? All I know is that it is working now. Thanks so much for your time and help..:-) You are awesome

    #343523

    Hi,

    I am glad it worked for you. Let us know if you need assistance with something else. Closing thread.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Getting Values From Combo Box

You must be logged in to post in the forum log in