For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub
- This topic has 6 replies, 2 voices, and was last updated 12 years, 5 months ago by
support-octavio.
-
AuthorPosts
-
mthaney4ParticipantHello 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.
October 16, 2013 at 6:58 pm #343433
support-octavioMemberIs your screen named Block-b1?? If yes, please try replacing the dash “-” for an underscore “_”.
result += “PSL Member: ” + $(“#m1-Block_b1-cmbTeamMemberBlock”).val() + “\n”;
October 16, 2013 at 8:23 pm #343436
mthaney4ParticipantHere is the layout
FrontPage.mobi
Block-b1.mobi
Block-b2.mobi
…
Block-b10.mobiAll 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.
October 16, 2013 at 8:25 pm #343437
mthaney4ParticipantHere 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);October 17, 2013 at 2:41 pm #343473
support-octavioMemberHi 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.
October 17, 2013 at 8:09 pm #343486
mthaney4ParticipantSo, 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
October 18, 2013 at 2:08 pm #343523
support-octavioMemberHi,
I am glad it worked for you. Let us know if you need assistance with something else. Closing thread.
-
AuthorPosts
