Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery : How to fill the input form automatically from text on webpage?
    text
    copied!<p>I have a project to filter 100k-200k of websites to gather the website's owner's name and emails, by viewing it on iframe. What I really need is if I click/select the name on the website I reviewed, it filled the name input form automatically, and the same for emails.</p> <p>Anybody know the solution? Any response will be appreciated.</p> <p>*if you need my code, just tell me and I will put it here. It's only an html page with <code>&lt;iframe&gt;</code> and <code>&lt;form&gt;</code>, though.</p> <p>Here`s the code:</p> <pre><code>&lt;div class="container container-harvester"&gt; &lt;div class="harvester-form"&gt; &lt;%= form_for(:harvesters, :html =&gt; {:class =&gt; "form-horizontal"}) do |f| %&gt; Name: &lt;%= f.text_field :name %&gt; Email: &lt;%= f.text_field :email %&gt; &lt;%= f.hidden_field :website, :value =&gt; "", :class =&gt; "website-harvester" %&gt; &lt;%= f.hidden_field :skipped, :value =&gt; "true" %&gt; &lt;%= f.submit "Submit", :class =&gt; "btn btn-primary submit-harvester", "data-disable-with" =&gt; "Saving..." %&gt; &lt;a href="#" class="delete-website btn btn-danger" data-id=""&gt;Delete&lt;/a&gt; &lt;% end %&gt; &lt;/div&gt; &lt;div class="harvester-iframe"&gt; &lt;iframe name="harvester-iframe" data-id="&lt;%= @websites.first.id %&gt;" src="&lt;%= @websites.first.url %&gt;" frameborder="0"&gt; &lt;/iframe&gt; &lt;/div&gt; &lt;div class="harvester-link"&gt; &lt;ul&gt; &lt;% @websites.each do |w| %&gt; &lt;% unless @registered.collect(&amp;:website).include?(w.url) %&gt; &lt;li&gt;&lt;a class="" href="&lt;%= w.url %&gt;" target="harvester-iframe" data-id="&lt;%= w.id %&gt;"&gt;&lt;%= w.url %&gt;&lt;/a&gt;&lt;/li&gt; &lt;% end %&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;% content_for :unobtrusive_js do %&gt; &lt;script type="text/javascript"&gt; $(document).ready( function() { $('.harvester-link a').on('click', function (e) { var url = $(this).attr('href') , id = $(this).attr('data-id') , $el = $(e.currentTarget); $('.harvester-iframe iframe').attr('src', url); $('.harvester-iframe iframe').attr('data-id', id); $('.website-harvester').attr('value', url); $('.delete-website').attr('data-id', id); $('.submit-harvester').attr('data-id', id); $('.harvester-link a').removeClass('active'); $el.addClass('active'); }); $('.harvester-iframe iframe').on('load', function (e) { var url = $(this).attr('src') , id = $(this).attr('data-id') , $el = $(e.currentTarget); $('.delete-website').attr('value', url); $('.delete-website').attr('data-id', id); $('.website-harvester').attr('value', url); $('.submit-harvester').attr('data-id', id); }); $('.delete-website').on('click', function (e) { e.preventDefault(); var id = $(this).attr('data-id'); API.delete(Routes.harvester_website_path(id)).done(function (response) { window.location.reload(); }); }) $('.submit-harvester').on('click', function (e) { var id = $(this).attr('data-id'); API.delete(Routes.harvester_website_path(id)).done(function (response) { window.location.reload(); }); }) }); &lt;/script&gt; &lt;% end %&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload