1

The last thing I cant get to work is to make this part .namefield.value = 'name'; to be based on a textarea.

I've tried altering the value part .value = 'name' to be directed to the form/id's to the textarea itself but that didn't work.

The textarea with submit button I've tried to use comes from dreamweaver;

<form id='input' method='post' action='' >
   Name: <input type='text' name='Name' />
   <input type='submit' name='submit' value='submit' />
</form>

The html/JavaScript which I am learning with is:

<html>
<head></head>
<body>
<iframe id="main" width="1000" height="1000" src="main.php"></iframe>
<button id="btnMain">Go</button>
  <script>    
     function load() {
        var btn = document.getElementById('btnMain');
        btn.onclick = function(){
        var ifrm = document.getElementById('main');
        ifrm.contentWindow.document.forms['searchForm'].namefield.value = 'name';
     };    
   }
   window.onload = load;
  </script>
</body>
</html>

In JSFiddle: http://jsfiddle.net/Tim_Holt/0a9krnao/

6
  • what is searchForm Commented Sep 30, 2014 at 19:17
  • Thats the formid of a form in main.php. On this moment if i click the button, it places 'name' in the field on that form Commented Sep 30, 2014 at 19:24
  • if ifrm.contentWindow.document.forms['searchForm'].namefield.value = 'name'; puts name in the field you want to read, then just use x=ifrm.contentWindow.document.forms['searchForm'].namefield.value; to access that value? Commented Sep 30, 2014 at 19:28
  • I think thats the other way around, the thing i like to have is not to display the word 'name' in the field of the form on main.php, but the value of a textbox to be placed in the form on main.php. Commented Sep 30, 2014 at 19:33
  • the value of the textbox in the iframe? Commented Sep 30, 2014 at 19:35

1 Answer 1

1

Here's a fiddle for my solution to your problem - http://jsfiddle.net/1nqdsyhu/ Here's the snippet of HTML/jQuery code

HTML

<button id='btnMain'>Enter</button>
<input type='text' name='value instead of 'name'' value='Write your name here' />
<ul>
</ul>

</br>
</br>
The frame wich has the form hasnt been includedbecause i dont know how to, but the form        above should be the value instead of the word 'name' shown as value in de javascript, wich at this point will be placed in the iframe form.

jQuery

$(document).ready(function(){
    $('#btnMain').on('click', function() {
        $('ul').append('<li>' + $('input').val() + '</val>');
    });

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.