I'm afraid I'm asking something simple, but I'm really stuck... I've googled the Internet, I've search this forum, but unfortunately what I've found wasn't very useful...
I need to add some read-only text to the form after user submits it.
1) I've added a textarea box with id 'result', a custom code element on the submit event where I'm setting the text this way:
It works but I can't make the textarea box read-only. I'v tried the following things in JS:
Nothing worked... I added the code on the load event, on the submit event, I moved it before "Show HTML" and after - still no luck. I've read this article: http://www.chronoengine.com/faqs/3678-how-can-i-add-an-attribute-to-a-form-input.html , tried to repeat these actions (for the textbox) but it has no effect.
So I'v tried another approach:
2) I've added a custom HTML/PHP element, set its code to this:
But now I cannot set/change the text of the div. I've tried several things:
None of it worked.
It drives me crazy🙂, it seems to be so simple yet I can't do anything.
Sorry if I missed some important information or haven't stated something clear - English isn't my native language.
Thanks a lot in advance!!!
I need to add some read-only text to the form after user submits it.
1) I've added a textarea box with id 'result', a custom code element on the submit event where I'm setting the text this way:
$form->data['result']='my custom text';
It works but I can't make the textarea box read-only. I'v tried the following things in JS:
document.getElementById("result").readOnly=true;
document.getElementById("result").setAttribute('readonly', 'readonly');
document.getElementById('result').setAttribute('readOnly', 'true');
result = $('result');
result.readOnly=true;
$('result').readOnly='readonly';
Nothing worked... I added the code on the load event, on the submit event, I moved it before "Show HTML" and after - still no luck. I've read this article: http://www.chronoengine.com/faqs/3678-how-can-i-add-an-attribute-to-a-form-input.html , tried to repeat these actions (for the textbox) but it has no effect.
So I'v tried another approach:
2) I've added a custom HTML/PHP element, set its code to this:
<div id="testresult"></div>
But now I cannot set/change the text of the div. I've tried several things:
document.getElementById('testresult').innerHTML="test1";
document.getElementById('testresult').textContent = 'test2';
document.getElementById('testresult').appendChild(document.createTextNode("test3"));
$('testresult').html('test4');
None of it worked.
It drives me crazy🙂, it seems to be so simple yet I can't do anything.
Sorry if I missed some important information or haven't stated something clear - English isn't my native language.
Thanks a lot in advance!!!
OMG, I get it! I missed one simple thing. All these brilliant pieces of code cited above work!
I have them in "Load JS" block On Submit event, but in turn they have to be on load event inside this block:
So here is the final scheme:
On Submit
\Show html
\Load JS
\\window.addEvent('load', function() { $('result').readOnly=true; } );
I have them in "Load JS" block On Submit event, but in turn they have to be on load event inside this block:
window.addEvent('load', function() { /**/ });
So here is the final scheme:
On Submit
\Show html
\Load JS
\\window.addEvent('load', function() { $('result').readOnly=true; } );
Hi ATAT,
Sorry I didn't get to this sooner; and well done for finding the solution.
Using window.addEvent('domready', function() { /**/ }); will also work and will run a little earlier when the DOM is loaded as it doesn't have to wait for images and other stuff to load.
Bob
Sorry I didn't get to this sooner; and well done for finding the solution.
Using window.addEvent('domready', function() { /**/ }); will also work and will run a little earlier when the DOM is loaded as it doesn't have to wait for images and other stuff to load.
Bob
This topic is locked and no more replies can be posted.