Skip to main content
Nintex Community Menu Bar

Button to Set Field Value (JS)

  • August 2, 2016
  • 5 replies
  • 429 views

Forum|alt.badge.img+7

Hi All,

I am very new to JS.

I want a series of buttons, when one of them is clicked, it will write a certain value to a text field hidden on my form.

I have given my single line text box a JS ID, called "TabRules".

On button1, I have set client click to "Tab1Function()"

Now I need help writing that function!

I tried this but no luck:

function Tab1Function () {

NWF$("Tab1").click();

document.getElementById("TabRules").value = "My value";

}

5 replies

Forum|alt.badge.img+8

Hello Dave Georgopoulis​ you're close! Here's a few updates to your scripts that should get you working!

Custom JavaScript in Form Settings:

function Tab1Function () {

  NWF$('#' + TabRules).val("My value");

}

JavaScript within your custom button's Client Click property:

NWF$(document).ready(function(){

    Tab1Function();

});

A few Notes:

  • Since you're already calling the Tab1Function() within your button's client click property, this doesn't need to be a part of the function itself (removed this piece).
  • I also did a little clean-up inside your function and used a jQuery approach to assigning your new "my value."

Good luck!


Forum|alt.badge.img+7
  • Author
  • August 3, 2016

Wow! Thank you so much Patrick!

I can't believe I was "close" but I appreciate the encouragement!

The writing to the field is working perfectly!

Now I just have to figure out why rules won't fire!

thanks again happy.png


Forum|alt.badge.img+8

No problem Dave Georgopoulis​ – happy to help!


Forum|alt.badge.img+4
  • June 8, 2017

How can we do the same to set a value on a SQL request control. which is rendered as Label.


Forum|alt.badge.img+1
  • December 12, 2017

Hi Patrick,

I am wanting to do the same action with replacing a value, but I want to take a people picker field and set it to nothing. Is there a way to do this that you know of?