Page 1 of 1
Display name value from dropdown in a HTML object
Posted: Thu Mar 20, 2014 3:05 pm
by rnott
Is there a way to display the name value (that is currently selected) from dropdown in a HTML object?
I know you can use the field name in a hash tag on the HTML tab to get the id value, but I need the name value.
The user would like to view its value on a different tab.
Thanks!
Re: Display name value from dropdown in a HTML object
Posted: Fri Mar 21, 2014 4:35 am
by admin
rnott,
$('#sex').text() = 'Male';
$('#sex').val() = 'm';
Is text() what you want?
Steven
Re: Display name value from dropdown in a HTML object
Posted: Fri Mar 21, 2014 2:24 pm
by rnott
yes I would like the text value to be displayed in a nuBuilder HTML object.
thanks,
Re: Display name value from dropdown in a HTML object
Posted: Sun Mar 23, 2014 6:47 pm
by massiws
rnott,
place you html object where you want and give it an id (ie:
<div id="mytext"></div>);
In
Javascript tab of your form insert some code like this:
Code: Select all
function nuLoadEdit() {
$( "#mytext" ).val( $( "#your-dropdown-field-id option:selected" ).text() );
}
This will display the value of dropdown in your html object every time the form is loaded.
Then, to make sure that every time you change the dropdown value also the html object change accordingly, insert a new event in
Event tab of your dropdown object:
Code: Select all
$( "#mytext" ).val( $( "#your-dropdown-field-id option:selected" ).text() );
Obviously, you have to change
"mytext" and
"your-dropdown-field-id" to your needs.
Have a look at
this video tutorial about
Events in nuBuilder.
Hope this helps,
Max
Re: Display name value from dropdown in a HTML object
Posted: Tue Mar 25, 2014 8:49 pm
by rnott
Thanks! Its working!
Here's what I did.
Hope this helps someone!..
On HTML tab for the HTML object create id --> <div id="htmlObjState"></div>
Then paste the following code in form properties --> Custom Code --> Javascript tab:
function nuLoadEdit() {
loadDlStateNo();
}
function loadDlStateNo(){
// Get the text value from the dropdown
dlstate=$( '#emp_dl_state_id option:selected' ).text();
// Get the Driver License # value from the text object
dlno=$( '#emp_dl_no' ).val();
//alert(dlno);
// Concatenates State & Driver License # & set the text value for the HTML object
$("#htmlObjState").text(dlstate + ' ' + dlno);
}
Then go to the dropdown object properties --> Events Tab
Event Name = onchange
Javascript = loadDLStateNo();
Thanks
Re: Display name value from dropdown in a HTML object
Posted: Tue Mar 25, 2014 9:06 pm
by massiws
.