add a text field on click of a link: javascript disabled - javascript

How do I add a text field on click of a link inside a form when javascript is disabled? It should not refresh the page and should store the form values which are present earlier.

Since Javascript is disabled, the interaction should occur using a server. You should call an appropriate event on the server and this latter will return the page with an added textfield.

Related

Submit Lotus Notes XPage form from outside with plain JS

I have a simple Lotus Notes XPage with only an editable RichText dialog that is embedded in a bigger form using an iframe.
The bigger form has a submit button, which triggers some javascript and finally a notes agent which saves all non-richtext values that are inside the bigger form.
Of course the user shall not have to use two submit buttons, so I won't have a (visible) submit button for the XPage. Instead, I want to use javascript to tell the iframe to submit the form.
Using iframe.document.forms[0].submit() does not work - the form is indeed submitted to the Notes server, but XPages won't save the changes I made.
Using a simple XPage button with the action "Save Data Sources", saving works like a charm, but I don't want the user to have to click two buttons in the correct order.
I also tried the following javascript code to fill some invisible fields with the values that IBM submits to the server, but this does not help either:
iframe.document.forms[0].elements["view:_id1:inputRichText1_h"].value = iframe.document.forms[0].elements["view:_id1:inputRichText1"].value;
iframe.document.forms[0].elements["view:_id1:inputRichText1_mod"].value = true;
iframe.document.forms[0].elements["$$xspsubmitid"].value="view:_id1:_id4";
iframe.document.forms[0].elements["$$xspsubmitscroll"].value="0|0";
iframe.document.forms[0].submit();
So now I ask you: how to correctly submit that form content, without the user actually clicking the XPages button? Can I programmatically trigger a click on that button, which would be indifferent from a human actually clicking, except for the human?
have an ordinary div with a fixed id and inside this div have a computedtext that will compute the clientsideid of the "save button" and return that inside the div
and use this clientside js code to do the actual click
var id=iframe.document.getElementById("button").innerHTML
var button=iframe.document.getElementById(id)
button.click()

Jquery val is not working when try to get a value from a form

I've tried to insert a form in woocommerce product page. I've inserted the form in the product page. When the form is submitted I'm trying to get the email (form input value) and validate it accordingly.
The problem is I'm not able to get the value in some theme using jQuery. I see the form and its elements in firebug. But jQuery is not even working for the click event in variable product (woocommerce product page). Here the form is inside their form (which enctype is multipart/form-data), this might be one reason or if I place the form above the variable product form jQuery it works but it returns empty string.
Even if there is some text inside the form input field, it returns empty string.
Here is the form
Here is the jQuery On submit click
jQuery(document).ready(function() {
jQuery('.mailsub').click(function() {
var subaddress = jQuery('.subemail').val();
console.log(subaddress);
if ( jQuery('.subemail').length > 0 ){
console.log('the element with element_id exists in the DOM');
}
//ajax goes here followed by validation for the email
return false;
});
});
I've tried to check whether it is in DOM or not, so I've used the code, it says the element with element_id exists in the DOM.
I'm able to get the form completely work on twentyeleven and defaults themes. It is working in wordpress defaults themes but not in some other third party themes.
What might be the problem? Any suggestion would be much helpful.
The HTML and code as given should mostly work. I'm guessing that there is another element with the class subemail earlier in the document. When you do jQuery(".subemail").val(), jQuery finds all of the matching elements, but then returns the value (if any) of only the first of them.
Side note: If you step through the code with the debugger built into your browser, rather than doing console.log statements, you can inspect variables as the code is running, which is dramatically more educational, usually.
Side note 2: Some browsers submit forms when the user presses Enter in a text field. In that case, the click event on the submit button may not be fired (since the button wasn't clicked). To reliably hook into the form submission process, use the submit event on the form, rather than the click event on the button.
Side note 3: You've said you're using ajax to validate the email address. By default, ajax calls are asynchronous, which means you cannot use the result from the server to decide whether to submit the form, because you don't get the result until after the submit event handler has returned and (probably) the form has already been submitted. You can make the ajax call synchronous, but that locks up the UI of most browsers while the call is in progress, leading to poor user experience. I suggest validating the email address via ajax when the field changes, and then again on the server when it receives the form (you can never rely on client-side validation). That lets you give the user proactive feedback (the on-change validation) without trying to validate it via ajax when submitting the form.

Submitting selection box item when javascript disabled

This is the case. I want to pass onchange event to a page (actually to the page this call is coming from) without having javascripting available. There is a tag with address like this:
<form name='form1' action='http://mysite.com/index.php' method='get'>
The select tag takes onchange event:
<select name='alue' onchange='this.form.submit();'>
I want to pass a particular, restricted list of choices to another selection box, based on the first selection box selection. I would like this to happen when javascript is disabled but is this impossible? Is this totally a client side event? Is there a way to perform this action purely with php (by forcing the page to reload somehow)?
The point is to have an alternative way for user to restrict amount of choices when javascript is disabled. Thank you for any advice and suggestion!
One approach is following :
Submit the form generally i.e through submit button then you can check in POST variable if the select box was selected or not.
if select box have value you can pass the form data using PHP to your page.

Check to see if a user has came from a 'forward' page

I am currently working on a form which posts to a web service. The form validation is done at the web service and if a validation error occurs the user is presented with an error and a back button.
The form contains a number of default values which I am auto populating. These values then overwrite any values that the user has inserted when the back button is pressed.
Is there a way I can detect to see if the user has pressed the back button and prevent the auto population?
My guess would be you are filling these post load via JS? Because the value attribute should not override new values. If you are, I would just do a check to see if the field is empty before loading in the text.
Also, I would look into the placeholder attribute.
Pass a parameter as part of the URL that your back button sends the user to, then check to see if that parameter is part of the URL of the current page in your Javascript. If it's present simply don't populate with the default values.

load a new page when an html's selector changes without javascript

How can I (if at all) load a new page when an html's selector changes if javascript is disabled in the browser.
Can it be done?
I guess you mean the html select box having some page titles displayed and as soon as the user selects one of them the new page showes up.
This is not possible with out javascript - the only thing you could do is to add a submit button.
<noscript><input type="submit" value="go!"></noscript>
This button would only be displayed if javascript is not activated.
No, you cannot reload a page when a select box changes (if that's your question) without using a scripting language or similar.
Without a scripting language (that would be JavaScript if you want to be cross-browser), most form elements are "dumb", they hold their state and display user feedback.
So if you want to select a new page after selecting it in a form (combo box, list, radio buttons...), you have to add a submit button to send the choice to a server, and have a server side script handling the choice and serving the right page.
The good old Web 1.0 way... :-)
You can't. With HTML only, changing the selected option makes the value of that option to be sent to the server upon submit (either via the Enter key or a submit/button element). You can eventually set up the receiving script to send back a HTTP Redirect based according to the selected option.
You shouldn't. This kind of navigation widget implies the use of a mouse: somebody using the keyboard to navigate the page cannot even select the second option at all (as soon as the down arrow is pressed once the onchange() event activates). Do the right thing and add a submit button, with the page change activated by the onsubmit() event.

Categories

Resources