第1行遇到一点问题,回应食品品牌的内容......
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value=\"$brand\"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'.
$brand= $w->item(0)->childNodes->item(0)->nodeValue;
更新
$hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.musicDetailTitle4.value="'.$artist.'"; document.contactForm.musicDetailArtist4.value=4;">fill form'.$artist."-".$title."-".$id."</a>";
答案 0 :(得分:7)
它正在发生,因为变量不用单引号解析:
..."javascript:document.contactForm.itemDetailTitle4.value="'. $brand .'"; document...
使用连接,如上所述。
答案 1 :(得分:0)
仅在引号之间解析变量
echo 'Text $var'; //apostrophe will not parse variable
echo "Text $var"; //citation marks will parse
在你的情况下,你应该这样做,这样你就不必与之抗争:
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value="' . $brand . '"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'.
答案 2 :(得分:-1)
$brand= $w->item(0)->childNodes->item(0)->nodeValue;
第二
echo $hint='<a href="javascript:void(0)" onclick="javascript:document.contactForm.itemDetailTitle4.value="'.$brand.'"; document.contactForm.itemDetailBrand4.value=4;">fill form</a>'