Note that there are some explanatory texts on larger screens.

plurals
  1. POcopying data from a form field and placing it in an echo statement all within an $xml=simplexml_load_file function
    text
    copied!<p>I am loading and echoing data from an XML file through the <code>$xml=simplexml_load_file</code> function. Everything is working perfectly, the code is as follows ( in part ):</p> <pre><code>&lt;?php $xml=simplexml_load_file('testfeed1.xml'); $max = 12; $i = 1; foreach($xml-&gt;someTag as $feed){ if ($i &lt;= $max){ echo "&lt;span class='previewImage' name='{$feed-&gt;some-subTag}' style='background:url({$feed-&gt;imageTag}) no-repeat center;'&gt;"; $i++; } } ?&gt; </code></pre> <p>In this example, I am drawing a URL from a tag in the XML and placing it at the background for a given span, all the images in the array (if that is the right usage of the word) appear without any problems.</p> <p>What I would very much like to figure out is how to make the background in this short example change base upon an <code>onBlur</code> function set in a form field which is also on the page.</p> <p>So if I have the following code:</p> <pre><code>Image URL: &lt;input type='text' name='smallImage' id='someId' value='{$feed-&gt;imageTag}' /&gt; </code></pre> <p>As you can see the field is pre-loaded with the "imageTag" from the XML here as well.</p> <p>What syntax or function could I use to change the backgroud of the span above after a new URL has been written. I was under the presumption that the <code>onBlur</code> function would be the best. </p> <pre><code>&lt;input type='text' name='smallImage' id='someId' value='{$feed-&gt;smallImage}' onblur="document.find(.imagePreview#{$feed-&gt;some-subTag}).setAttribute("background", .smallImage.someId.value);" /&gt; </code></pre> <p>Again, I am complettely new to js and php.</p> <p>Thanks in advance for any tips, hints or tricks.</p> <p>/Brian</p>
 

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