read only text box if data is not preloaded - javascript

I have a screen which will be loaded dynamically along with countries,text boxes with some preloaded data and revert button next to them.
I would like to make the text boxes readonly/disabled if they are not having any preloaded data and not to show the button next to them.
Please let me know how it can be done.

When you get the input check if the textbox has a value if it doesn't make a call to a javascript method such as the on below.
document.forms['myFormId'].myTextArea.setAttribute('readonly','readonly');
i'm not sure about the disable of the button but if I had to take a guess I would when you are checking the input value if there is data display button otherwise skip

and disabled properties of text box, resolved my issue along with below code

Related

Updating the value of a Brazos Input Text control client side

We have a CSHS with a Data Table and Global Filter exposed. After entering a value in the filter and limiting the table, they want to be able to click a button that opens a modal and have it available in an input text in the modal and, by doing so, have it bound to a local variable in the CSHS so it can be used in scripts.
I am able to get the value to show up in the modal (code a bit kludgy but it works) but the input text on the modal doesn’t seem to think it has changed and isn’t binding the value to the variable bound to the input text. Suggestions?
Here’s the code I’m using to get the Global Filter text to display on the modal input text: (added a class name of “searchValue” to the input text in the modal – only one data table on the CSHS so I can use the [0] index of getElementsByClassName)
var el = document.getElementsByClassName('searchValue')[0];
el.getElementsByTagName('Input')[0].value = document.getElementsByClassName("dataTables_filter")[0].firstChild.firstChild.nextSibling.value;
Try calling the jQuery .change() on the input text field after changing the value.
For example:
$("#input_div_1_1_1").val("test").change()

Appending a bunch of check box inputs to a form before submission and then hiding them

For a form I'm building, I'm using a jQuery UI dialog to give the user a list of about 50 check box options. The text boxes get removed from the form completely when they're added to a dialog, so I have to clone and reinsert them to the form before submission so that all of the check box values will be submitted along with the form. The problem is that the checkboxes, when added back into the form, appear visibly. I'm just trying to make them invisible and still be able to submit the values.
I thought maybe doing something like prepend() might be a solution so that the user doesn't actually see the checkboxes, being all the way at the bottom of the form--but it still pushes the form elements down. So I'm looking for a means of appending the #states_container :input to the form without it visibly affecting the form in any way.
Code:
$('#submit_btn').click(function(e){
$("#form_submission").validate({});
if ($("#form_submission").valid()) {
$("#form_submission").append($('#states_container :input').clone());
$("form#form_submission").submit();
} else {
e.preventDefault();
alert("Please make sure all required information has been provided before submission.")
}
});
Create a div at the bottom of your form. Style it's display to none and give it a unique id.
<div id="checkBoxes" style="display:none;"></div>
When you go to clone the check boxes from your jQuery dialog set their location to:
document.getElementById("checkBoxes").innerHTML = varWithCheckBoxes;
This will place all of your check boxes inside an invisible div that will have no affect on your layout and will still be submitted along with your form. In addition if the need arises to repopulate that list of check boxes to make changes you can simply grab them from the div and place them back in the dialog box.

LinkButton value lost on PostBack

I have a table that I'm creating rows/cells in the code behind, and adding various controls to each cell. There is also as submit button on the form.
One of the cells contains an SPLinkButton. I have a Javascript function that changes the innerText/textContent based on user action from the default value set in the code behind. Prior to clicking the Button to run code behind, the end user does see the updated text of the SPLinkButton.
When the submit button is clicked, this is the only control that reverts its value back to the default value during the button's postback. A Label/TextBox/DDL all preserve their values. If I wrap the control in IsPostBack, the cell the control is added to will be null (or if I wrap the entire table, there will be no rows). Note that I'm using the value of another item to uniquely append the SPLinkButton ID on a per-table row basis.
What is different about LinkButton/SPLinkButton and postback behavior?
EDIT: I converted the SPLinkButton to a TextBox, providing similar functionality. While I dislike the presentation compared to the textbox (look and feel, as well as the SPLinkButton would automatically expand the modal size when needed), it does function. I would love to get SPLinkButton working and go back to using it, if possible.

PDF Form Button border change (Acrobat)

Creating a PDF form in Acrobat X. The form has various selections listed in a grid style, and my client would like when one of the selections is clicked on for a circle or square to be drawn around the selection. I have tried various methods to get this to work, but I keep running into road blocks. Here is where I am so far:
I have figured out that I can place a button on top of the text and set the border and fill of the button to clear, and have no text entered for the label. This basically makes the button a completely transparent box on top of the text.
What I would like to do is: when the transparent button is clicked, change the border color from transparent to black, thus creating a box around the word, and looking like the word is enclosed in the box. In the event that I can get some guidance in how to do this, I would also like for if the button is clicked a second time for the black border to return to transparent (in case the initial click is done in error.)
I am assuming this will need to be done by utilizing the javascript functionality of the PDF and assigning it to a button action Mouse Up. However, I must admit ignorance on what the code would be to accomplish this.
Any help would be appreciated.
I may get back to you on this, but a helpful resource is found at:
http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJSGuide.pdf
This is Adobe's reference on PDF forms, and includes information on Javascript used in their form calculations.
On page 267 of this document is this:
How can I hide an Acrobat form field based on the value of another?
Use the display method of the Global object:
var title = this.getField("title");
if (this.getField("showTitle").value == "Off")
title.display = display.hidden;
else
title.display = display.visible;
Five lines of code that goes somewhere. Maybe in the "calculate" portion of a field.
Line 1: Set a variable called "title" that represents the existing form field named "title"
Line 2: Start "if" statement that queries the value of field called "showTitle"
Line 3: If the value of showTitle is "Off", then set the field "title" to hidden
Line 4,5: Otherwise, default the display value of field "title" to visible
If the field called "title" here is a text box, you can put in some text that will be either hidden or visible. You could have a blank field with a border, maybe, to use as your hidden/visible border, if there is no fill color, I think.
The field "showTitle" can be a check box, where the value on check is "Off".
I hope this helps. I am trying this out myself right now.

Running function only if a certain element isn't burring

im making an application that creates a text input where ever you click. I was having a problem where whenever you would click inside the field another text field would appear but i managed to fix that. I have one last major issue that I just can't solve. I know ou can't use blur() and focus() as arguments (though it would be nice) but i need to find a way so that after you enter text into the input field and out click, it just blurs the input box and doesn't create another until the user clicks again.
Just create a variable to keep track or only use a certain ID for the input you create, then check for that variable or input element before creation..
if(!$("#myDynamicInputElement").length){
//TODO: Create your element..
}

Categories