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!
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Display name value from dropdown in a HTML object
-
- Posts: 31
- Joined: Fri Mar 14, 2014 6:14 pm
Re: Display name value from dropdown in a HTML object
rnott,
$('#sex').text() = 'Male';
$('#sex').val() = 'm';
Is text() what you want?
Steven
$('#sex').text() = 'Male';
$('#sex').val() = 'm';
Is text() what you want?
Steven
-
- Posts: 31
- Joined: Fri Mar 14, 2014 6:14 pm
Re: Display name value from dropdown in a HTML object
yes I would like the text value to be displayed in a nuBuilder HTML object.
thanks,
thanks,
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact:
Re: Display name value from dropdown in a HTML object
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:
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:
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
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() );
}
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() );
Have a look at this video tutorial about Events in nuBuilder.
Hope this helps,
Max
-
- Posts: 31
- Joined: Fri Mar 14, 2014 6:14 pm
Re: Display name value from dropdown in a HTML object
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
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
-
- Posts: 503
- Joined: Thu May 24, 2012 2:08 am
- Location: Milan, Italy
- Contact: