I am trying to get the value of dojo editor and append it to the hidden input. This code:
onClick="dojo.byId('editorContent').value = this.getValue()
works correctly if i put it in the div of the editor. However i want to update before send the form the hidden input. I already tried with onclick and onsubmit but didn't works.
Probably this is wrong :
content.getValue()
code
<form>
<div id="descricao_oferta">
<input type="hidden" name="item[editorContent]" id='editorContent' />
<div dojoType="dijit.Editor" id="content" height='200px'">
<?php echo isset($arr['conteudo']) ? $arr['conteudo'] : "Descrição";?>
</div>
<form>
<input id="send" name="send" type="submit" value="Registo" onClick="dojo.byId('editorContent').value = content.getValue()"/>
</form>
How can i update the hidden input with the content of the editor when submit the form ?
similar problem
source
this is the correct way:
onClick="dojo.byId('editorContent').value = dijit.byId('content').get('value')"
Shouldn't it be dijit.Editor.get('value'); to get the value from the editor?
http://dojotoolkit.org/documentation/tutorials/1.6/editor/
Related
I have a form with id theForm which has the following div with a submit button inside:
<div id="placeOrder"
style="text-align: right; width: 100%; background-color: white;">
<button type="submit"
class='input_submit'
style="margin-right: 15px;"
onClick="placeOrder()">Place Order
</button>
</div>
When clicked, the function placeOrder() is called. The function changes the innerHTML of the above div to be "processing ..." (so the submit button is now gone).
The above code works, but now the problem is that I can't get the form to submit! I've tried putting this in the placeOrder() function:
document.theForm.submit();
But that doesn't work.
How can I get the form to submit?
Set the name attribute of your form to "theForm" and your code will work.
You can use...
document.getElementById('theForm').submit();
...but don't replace the innerHTML. You could hide the form and then insert a processing... span which will appear in its place.
var form = document.getElementById('theForm');
form.style.display = 'none';
var processing = document.createElement('span');
processing.appendChild(document.createTextNode('processing ...'));
form.parentNode.insertBefore(processing, form);
It works perfectly in my case.
document.getElementById("form1").submit();
Also, you can use it in a function as below:
function formSubmit()
{
document.getElementById("form1").submit();
}
document.forms["name of your form"].submit();
or
document.getElementById("form id").submit();
You can try any of this...this will definitely work...
I will leave the way I do to submit the form without using the name tag inside the form:
HTML
<button type="submit" onClick="placeOrder(this.form)">Place Order</button>
JavaScript
function placeOrder(form){
form.submit();
}
You can use the below code to submit the form using JavaScript:
document.getElementById('FormID').submit();
<html>
<body>
<p>Enter some text in the fields below, and then press the "Submit form" button to submit the form.</p>
<form id="myForm" action="/action_page.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br><br>
<input type="button" onclick="myFunction()" value="Submit form">
</form>
<script>
function myFunction() {
document.getElementById("myForm").submit();
}
</script>
</body>
</html>
HTML
<!-- change id attribute to name -->
<form method="post" action="yourUrl" name="theForm">
<button onclick="placeOrder()">Place Order</button>
</form>
JavaScript
function placeOrder () {
document.theForm.submit()
}
If your form does not have any id, but it has a class name like theForm, you can use the below statement to submit it:
document.getElementsByClassName("theForm")[0].submit();
I have came up with an easy resolve using a simple form hidden on my website with the same information the users logged in with. Example: If you want a user to be logged in on this form, you can add something like this to the follow form below.
<input type="checkbox" name="autologin" id="autologin" />
As far I know I am the first to hide a form and submit it via clicking a link. There is the link submitting a hidden form with the information. It is not 100% safe if you don't like auto login methods on your website with passwords sitting on a hidden form password text area...
Okay, so here is the work. Let’s say $siteid is the account and $sitepw is password.
First make the form in your PHP script. If you don’t like HTML in it, use minimal data and then echo in the value in a hidden form. I just use a PHP value and echo in anywhere I want pref next to the form button as you can't see it.
PHP form to print
$hidden_forum = '
<form id="alt_forum_login" action="./forum/ucp.php?mode=login" method="post" style="display:none;">
<input type="text" name="username" id="username" value="'.strtolower($siteid).'" title="Username" />
<input type="password" name="password" id="password" value="'.$sitepw.'" title="Password" />
</form>';
PHP and link to submit form
<?php print $hidden_forum; ?>
<pre>Forum</pre>
I am trying to use the MDBootstrap WYSIWYG plug-in to enhance my forms, but am coming up short.
It does not seem to appear to be a class that can be applied to a textarea; doing so only displays the form element without the enhanced functions and toolbar. Instead, the docs say to create an instance as follows
<div class="wysiwyg" data-mdb-wysiwyg="wysiwyg" id="foo" name="foo">
However, when submitting a form that includes the above div, the value contained is not "posted" or "getted".
I have seen a post (https://mdbootstrap.com/snippets/standard/m-duszak/3256156#js-tab-view) that suggests what to do, using Javascript, but I don't understand it. The HTML they give (with the addition of the first textarea that I have added) is:
<form>
Title:
<textarea name="title" cols="60" rows="2"><?php echo $Story->title; ?></textarea>
<div class="first-area">
<div class="wysiwyg" data-mdb-wysiwyg="wysiwyg">
</div>
</div>
<button type="submit" class="btn btn-primary">
Submit
</button>
</form>
The JS is:
const formEl = document.querySelector('form');
const firstArea = document.querySelector('.first-area .wysiwyg-content');
formEl.addEventListener('submit', (e) => {
e.preventDefault();
alert(`Text area content: ${firstArea.innerText}, but you can also get HTML: ${firstArea.innerHTML}`)
})
What I need to do is get what is there into a $_POST or $_GET or via some method that I can then use to process for a MYSQL insert or update. Any help would be appreciated.
I'm working on a basic form that has one textarea and one submit button:
<form action="admin-post.php" method="post">
<textarea style="width:630px;" aria-hidden="true" class="wp-editor-area" rows="6" autocomplete="off" cols="71" name="author_message" id="author_message"></textarea>
<p class="submit">
<input type="submit" value="Post Message" class="button button-primary" id="submit" name="submit">
</p>
</form>
I want the submit button to be enabled only if there is some text entered within the textarea. How can I do this using Javascript?
Note that I cannot change the the value or HTML code of the submit button.
If you need continuous verification solve it like this (without changing the button attributes):
<textarea style="width:630px;" aria-hidden="true" class="wp-editor-area" rows="6" autocomplete="off" cols="71" name="author_message" id="author_message" onkeyup="if(this.textLength != 0) {submit.disabled = false} else {submit.disabled = true}"></textarea>
and modify the body tag:
<body onload="submit.disabled = true">
Cheers
JSFiddle
edit:
If you cannot modify the body tag, just add the disabled attribute to the button.
Working code here JSBIN :) i used HTML Disable attribute
You need to find the submit button in the DOM first and disable it and then attach an event listener to the textarea, wherein you disable/enable the submit button based on whether the textarea is empty or not:
document.getElementById("submit").disabled = true;
document.getElementById("author_message").addEventListener('change', func, false);
function func(){
document.getElementById("submit").disabled = (document.getElementById("author_message").value==='') ;
}
Here is the JsFiddle.
I want to pass a data that has been entered in a text box
Source page : page1.jsp Target page : page2.jsp
page1.jsp code
<input type="text" id="date" autocomplete="off" >
<br>
<button onclick='window.top.location.href ="page2.jsp?id=document.getElementByID('date').value">
onclick='window.top.location.href ="flush.jsp?id="document.getElementById('datepicker').value"'>
in what way can i pass the value entered in the text box through via href attribute ??
You have to concatenate the string in javascript. I think you have mix up javascript code with JSP script i.e. page2.jsp?id=<%=date%> (this is JSP scripting)
<button onclick='window.top.location.href="page2.jsp?id=" + document.getElementById("date").value;'>Submit</button>
Try using this--
<input type="text" id="date" autocomplete="off" value='ABC'/>
<br>
<button onclick='window.location ="page2.jsp?d="+document.getElementById("date").value'>Click me </button>
Heres the working Fiddle
I was wondering how can I submit div data to MySQL. Im not used to javascript so I dont really know whats happening on the javascript part but how can I get or input the action="" part and method="" part and can I or should I add value="" to the hidden input???
Form html code:
<form onsubmit="document.getElementById('hidden_data').value=document.getElementById('showing_data').innerHTML;">
<input id="hidden_data" name="data" type="hidden"/>
<div id="showing_data" class="commenttext" contenteditable="true"></div>
<input type="submit" Value="Enter" id="submitthis">
</form>
Use the hidden field inside the form tag and use the JavaScript to put the value inside it. You can get the hidden field in the $_POST['hydName'].Put the data on the click of the submit button into the hidden field. Keep your action and method of the form same as required. After the click event is fired, it will submit the form to its action URL
<input type="submit" onclick="document.getElememtById('hidden').value = document.getElementById('div').innerHtml;" />