Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could use Jquery to do this easily.</p> <p>Grab a copy of Jquery from <a href="http://www.jquery.com" rel="nofollow">http://www.jquery.com</a> or use the CDN version by pasting this into your head section:</p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt; </code></pre> <p>Here's a simplified version:</p> <p>If the start and end parts of your URL are not going to change you could simplify your form:</p> <pre><code>​&lt;form&gt; &lt;label&gt;Model Num&lt;/label&gt; &lt;input type="text" name="model" id="model" /&gt; &lt;input type="button" value="Update Image" id="update" /&gt; &lt;/form&gt; &lt;img src="" /&gt; </code></pre> <p>​ Then With the following Jquery code, you can detect a click on the update button, grab the code from the text box and change the image src attribute to </p> <pre><code>http://mysite.com/products/typed_code_here </code></pre> <p>Just paste the jquery code (and the script tags) into your head section</p> <pre><code>&lt;script&gt; ​$(document).on('click','#update',function(){ $('img').attr('src','http://mysite.com/product/'+$('#model').val()+'.jpg'); });​​​​​​ &lt;/script&gt; </code></pre> <p>If you want to do this <strong>without Jquery</strong> and if your html has to remain as above, you could use the following along with your original html (watch out for spelling mistakes in your code):</p> <pre><code>&lt;script&gt; var model_input = document.getElementById('model'); var start = document.getElementById('start'); var end = document.getElementById('end'); var image = document.getElementsByTagName('img'); model_input.onkeyup = function(e){ image[0].src = start.value + model_input.value + end.value; } &lt;/script&gt; </code></pre> <p>The onkeyup event could be changed to blur, change etc depending on how you want to update the image. I'd suggest a button such that the user can update the image when they believe the code is valid. </p> <p><strong>Update</strong>​</p> <p>The following github project has made progress on the front of cross domain html requests with jQuery. <a href="https://github.com/padolsey/jQuery-Plugins/tree/master/cross-domain-ajax/" rel="nofollow">https://github.com/padolsey/jQuery-Plugins/tree/master/cross-domain-ajax/</a></p> <p>Basically you'd just need to grab the product page via ajax (jQuery.ajax()) and then in the ajax callback you'd have to scan the returned HTML for the h1 element. Ultimately cross domain ajax is a design pattern and there are best practices associated with it. Grabbing the whole HTML page for the sake of an h1 element is not very effective. Consider revising your approach and be sure to check any copyright laws/terms and conditions if the site you're referencing is not your own.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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