I have created a new window and have fields that need to be completed, one a text field (for a numeric value) and the other is a radio button option (choose between 7 radio buttons). I can enter text and select a radio button but cannot obtain the value for the field id, e.g. myWindow.document.write ('Copies required: ') and for the button choice
myWindow.document.write ('6x4 ').
How do I obtain the value for copies and tell if the radio button has been checked. Have displayed the value for copies and always says undefined. Any help would be very much appreciated. Thanks.
How did you displayed the value?
In simple javascript it should be a code like:
alert(document.getElementById('IdofyourObject').value);
If you are using jQuery it would be:
alert($('#IdofyourObject').val());
Maybe you can share your code.
Related
I'm soliciting your help.
I made a form that I'd like to use at my job. As i have to make reports all day long, I though it'd be faster to have a form already ready to be copied/pasted in the software I use.
Here is a fiddle of what I've done so far : http://jsfiddle.net/5j0mfero/
When I fill "description" field, it does write everything in the "Preview" textbox but I don't succeed for other textboxes and checkboxes.
Things are that I'd like it to be pre-formatted this way :
Description : //value of description's field
Equipment : // value of equipment
Tests : █ // value of checkbox
█ // value of checkbox
█ // value of checkbox
█ // value of textbox "other"
Option : // values of "option" checkboxes comma separated
Terminal : // values of checkboxes + textbox "other"
Is it possible to do it with jquery or javascript ?
If yes, how should I do ?
Then afterwards I'd add a button in order to copy the preview box.
Thanks for your answers.
Check out this fiddle :).
Also, click on the Generate Report button to get that formatted string you wanted instead because I couldn't think of way to have it dynamically generated every time any of the fields above get modified.
Is there way that i could identify where a radio option value gets changed, either thru watch expression on firebug or inspect element ?
i am remote debugging a website and there are 4 radion buttons in the website. We set the CHECKED property for my 4th option as true, it gets checked. But after a sometime(1 sec) my first option gets selected automatically. There are too many javascript code involved and i am not sure where to check.
So is there any way i can do a debug-BREAK when a watch expression fires or any other way to debug this?
You can do this using jquery:
$('input[type=radio][name="inputName"]').on('change',function(){
//#myForm is the id of the form that the radio box in
alert($('input[name="inputName"]:checked', '#myForm').val());
});
This will alert the new value of the radio box when changed JsFiddle
I have used ng-disabled for my form validation for ADD button.
i.e. ng-disabled="conditionForm.$invalid". But , My form contains two text boxes which are hidden at first , and when a type is selected from drop down , only the respective Text box div should be visible. The Problem i'm facing is ,when the above ng-disabled validation is used , the ADD button is still disabled when one of the text box is selected and an input is provided. After the second input is also selected from the drop-down , then the ADD button is getting enabled.
Can you please provide me with an alternate validation , where the ADD button can get enabled every time a value is selected from drop down and a valid input is provided.
If you're ng-disabled is on a form being valid or invalid it sounds like those may have required inputs set. If that is case look at using ng-required so you can explicitly set required based on expression. You can then control when the form is valid.
The exact answer: Answer
My objective is to accumulate results of a multi-page questionnaire form into a summary page. Specifically I wish to take the selection from radio buttons and check boxes and place their values into another field on the summary page. This works fine when the radio button selections are numbers. I use the following script in the calculation pane (Custom calculation script) of the destination field of the summary page e.g.
var v1 = +getField("Hx.LBPWorst").value;
event.value=v1
The variable Hx.LBPWorst is a radio button with 11 buttons, 0-10 and the selected option is transferred to another field on the summary page without problems
My problem is that I wish to transfer text choices rather than numbers from a radio button E.g.
The radio button Hx.mech.prosit has four options “Worse”, “Better”, “NE”, “Varies”. The destination field for the selected option is a field with the format set to “None”. I have attempted to use the same structure i.e.
var v2 = +getField("Hx.mech.prosit").value;
event.value=v2
In this case the destination variable is filled with NaN i.e. Not a Number. I have read some of the questions and answers in this forum and apparently the problem is that radio buttons actually don’t store the selection as text. How can I achieve my objective and still use radio buttons (or check boxes)?
Change +getField to getField
var v2 = getField("Hx.mech.prosit").value;
The Unary plus (+) is changing the string to a number. When it can not convert it to a number, you get the NaN.
I'm currently working on a Lotus Notes solution. We're just using Web forms so client side operations are done via Javascript.
What I want to accomplish is to reset a Group of Radio Buttons. There are 3 possibilities and I want to choose none. (A 'none of them' possibility would be preferable, I know but we are required to reset them)
I currently use:
//Unchecks a single group of Radio Buttons
//groupname - the name attribute of the group which selection needs to be unchecked
function clearRadioButtonGroup(groupName) {
for(i=0;i<document.forms[0].elements[groupName].length;i++) {
document.forms[0].elements[groupName][i].checked = false;
}
}
The problem with this routine is, the Radiogroup gets reset, but on a form submit the old value gets submitted. Any suggestions?
What version of Domino are you using? Since 7.x (I think) a %%Surrogate field gets generated as a hidden field in your HTML that you'll be able to reset, so after deselecting all of the radio button options, you can then clear out the %%Surrogate field and you should then avoid having to select a "None of the above" option.
Matt
The problem is that clearing the radio buttons make no information about them appear in the submitted form data, and Domino seems to interpret that as no change to the field rather than clear the field.
I haven't found any solution to this I really like, but I can think of two options:
Change the radio buttons to include a no choice option.
The alternative is a bit clumpsy:
Add an editable field to the form to use as a flag, hide it from the web browser with css.
Have clearRadioButtonGroup also set the flag field to something.
Have the onChange event of the radio buttons clear the flag field.
In a WebQueryOpen agent, set the radio buttons field to empty if the flag field is non-empty.
Another alternative could be to uses some clever javascript/css trick to hide the no choice option and have clearRadioButtonGroup simply set that choice.
Are you certain that the old value is actually being submitted? Perhaps it just isn't being updated (erased) in the NotesDocument you're editing? Just a hunch...
BTW, you can download a program called Fiddler that will let you inspect the HTTP POSTs, and you can confirm that the POST data doesn't contain any values for that radio button group. That might help narrow down the problem.
Put the following pass thru HTML code on your form:
<input type="hidden" name="FieldName" id="FieldID" value="">
(FieldName and FieldID are the name and id of your radio field on the form)
When you reset your radio through Javascript and submit your document, the field will be reset to blank.