从表单字段复制数据并将其放在echo语句中,所有这些都在$xml=simplexmlload_file函数中


copying data from a form field and placing it in an echo statement all within an $xml=simplexml_load_file function

我正在通过$xml=simplexml_load_file函数从XML文件加载和回显数据。一切都很完美,代码如下(部分):

<?php
$xml=simplexml_load_file('testfeed1.xml');
        $max = 12;
        $i = 1;
foreach($xml->someTag as $feed){ 
if ($i <= $max){
echo "<span class='previewImage' name='{$feed->some-subTag}' 
style='background:url({$feed->imageTag}) no-repeat center;'>";
                $i++;
            } 
          }  
    ?>

在这个例子中,我从XML中的一个标记中绘制一个URL,并将其放置在给定跨度的背景中,数组中的所有图像(如果这个词的用法正确的话)都会毫无问题地出现。

我非常想弄清楚的是,如何使这个简短示例中的背景基于页面上表单字段中设置的onBlur函数进行更改。

所以如果我有以下代码:

Image URL: <input type='text' name='smallImage' id='someId' 
value='{$feed->imageTag}' />

正如您所看到的,该字段也是用XML中的"imageTag"预加载的。

在编写了新的URL后,我可以使用什么语法或函数来更改上面跨度的背景。我认为onBlur函数是最好的。

<input type='text' name='smallImage' id='someId' value='{$feed->smallImage}' 
onblur="document.find(.imagePreview#{$feed->some-subTag}).setAttribute("background", .smallImage.someId.value);" />

同样,我对js和php完全陌生。

提前感谢您的任何提示、提示或窍门。

/Brian

尽管很遗憾,我还是对Dreamweaver中内置的图像交换函数进行了优化,以解决这个问题。

Dreamweaver有一个代码,它使用mouseOver交换图像,使用mouseOut恢复原始图像(我相信大多数人都知道这一点)。

我只是简单地使用onBlur函数来交换图像,省去了任何恢复交换,然后我玩了它,这样预览图像就可以与在某个字段中输入的图像源进行交换。

<p>
<img name='flipflop{$feed->individualTag}' src='{$feed->smallImage}' />
</p>

这上面的代码是一样的。

对于字段输入:

onblur="MM_swapImage('flipflop{$feed->individualTag}','',(this.value),1);" />

当然,我复制了MM swapImage脚本并放在文件中。。。。明显地

没有魅力,没有智慧,没有创造力,没有才华。。。。。但是功能性的。

对于一个和我一样了解js、jquery和php的人来说……功能是王道。