I've looked everywhere on this.
basically what I have is a script that changes the value of some fields based on a radio selection.
For example: Think of it like a radio button that gets credit card data.
it works initially when the page loads and selects a radio. It will correctly load the data of that radio button.
Now when I choose to edit the fields manually, using it like a "new card" form, if I change my mind and go to select a presaved card, it will no longer update those fields I edited manually. It will completely ignore my request for it to change values via my javascript code that was just previously working. Note: It will actually still continue to work for any fields I left alone *did not manually type into/edit
so I was just wondering who else had that problem and what one does to fix it.
I am not sure if I understand exactly but I'll take a shot. My suggestion would be set apply a css class like "is-dirty" to the field once it has been updated and then you check to see if a given field has that class before updating it.
Related
I'm using Materialized CSS and it works very well for me. However when I added more dynamic behaviour to my app, for example when I'm pre-populating form with values and appending them to the layout, here is the photo of that:
That happens only when I preset the value to form on/prior to page load (because my form html is generated by server side).
However if I were to click into the quantity field then quantity would go back to its place and it would stay there.
How do I make it so that it stays up even when I pre-populate the form value? Is there a class I need to add to it (label or input) or JavaScript or something that I can put out there.
If you want to pre-fill text inputs, use Materialize.updateTextField(); as the docs says
I use JavaScript to set required level of field based on some selections, the field appears as optional but the form doesn't able to save and says please fill this field.
My code
Xrm.Page.ui.controls.get("new_field").setRequiredLevel("none");
I don't know why this happen i tried to hide the field using this code
Xrm.Page.ui.controls.get("new_field").setVisible(false);
it hides the field but when i press save the field appears again like a charm and cannot save the form.
The script doesnt look quite right,
setRequiredLevel
Xrm.Page.getAttribute("new_field").setRequiredLevel("none");
Visible
Xrm.Page.getControl("new_field").setVisible(false);
So basically I wanted to make a thing like this. A search button which is disabled. than when somebody enters something in one of the fields of the form I want button to enable itself and if somebody cleans every input up than I want to disable that button back. So my Idea was something like this. Extend the button provided by Ext JS. and somehow when this button is drawn or initialized, attach event of value changed to its upper form's input fields. so basically when somebody changes value of any input, that method attached as a listener will be called and than with help of some logic I can achieve the thing I want. but there is one problem. I don't really see how to do that. I mean I have some guesses but all of them have led me to the dead-end. So can you suggest what can I look at or from where to start ?
You can use formBind to enable/disable button depending on the validity state of the form. Validity of the form fields are checked against the validators set for form fields (like allowBlank: false). See the Example usage here
Another way to validate is to use VTypes
But, for the specific requirement to enable button if user enter values in any one of the fields, you might require custom validators. Sample fiddle here: https://fiddle.sencha.com/#fiddle/5qe
On a Jsp page I have some select elements which were disabled after a value was selected (Disabled them in javascript). Now when the form is submitted, I can not access those selected values in the action class.
I know for sure that this is caused by the select elements being disabled because, when I tried the same without making them disabled, it worked fine.
Now I don't understand why is this so. I thought maybe I should enable them before the form is submitted, but it does not seem a good idea.
I faced this problem while implementing this : Creating struts 2 forms dynamically on jsp using java script .
(You can find the code there. Although I don't think you will need the code, because it is clear where the problem is.)
Here I am able to access the values of text fields but I can not access the values of select elements.
I asked this question separately because I thought this is a different topic.
Thanks!!
Disabled fields by W3 specifications will not get posted on the server side so this issue is not related to the Struts2 but in generic an HTML way to go
Disabled controls
i am not sure why you want to use disabled control for your form.things can be done using readOnly attribute or use hidden fields
You can set them in hidden field through java script and pass it to action
Im trying to create a page that allows a user to select a maximum of 8 checkboxes out of 25 checkboxes total, While at the same time detecting the exact order the user clicked the checkboxes.
My question is, What code can I add to the javascript to gather this info and pass it along to a page named check_combination.php I have been told that this would be a hidden field, But being a noob Im stuck. Can someone please tell me what code i would need to gather it, and what type of code I would nee to extract it on check_combination.php
Here is an exaple of what I have so far Click Here to test in Real Time at JSFIDDLE
I am a noob to javascript, but I have been able to piece together various snippets of code to get as far as I have. The only thing I am missing is Im not sure how to pass the variables along when a user hits the submit button.
You're already there. After you submit the form the result values will be submitted as well, and you can find them in $_POST['result'] using PHP.