Live preview: parsing carriage returns
Moderator: General Moderators
Live preview: parsing carriage returns
how would I go about registering line breaks in a rpc preview?
I tried using nl2br() server side, it didn't work though so i'm guessing the carriage returns aren't being sent in the http request, i assume therefore it has to be done clientside?
I tried using nl2br() server side, it didn't work though so i'm guessing the carriage returns aren't being sent in the http request, i assume therefore it has to be done clientside?
All i'm doing is simply applying .innerHtml to a div node
so i thought if i nl2br'ed it server side it would register the breaks client side - but i dont think it's getting the carriage returns when it's first being sent with xmlhttprequest.. i'm just sending a get request with the value of the input field, then printing that value back to my callback function and attaching it to an empty div.
so i thought if i nl2br'ed it server side it would register the breaks client side - but i dont think it's getting the carriage returns when it's first being sent with xmlhttprequest.. i'm just sending a get request with the value of the input field, then printing that value back to my callback function and attaching it to an empty div.
Hmm I guess it's hard for you to say without seeing the whole source. I think I've come across a decent blog post which will help so ill post if theres any solution.
Perhaps instead someone could help me solve this bug. for some reason on my live search script which uses divs within an iframe - it doesn't assign the onclick to the first div so when you click on the first search result it doesnt close the div, but fine on the rest of them. (http://diabli.com/gs/livesearchIFRAMEv3.htm)
Result of what happens (first 2 divs)

Related code:
Perhaps instead someone could help me solve this bug. for some reason on my live search script which uses divs within an iframe - it doesn't assign the onclick to the first div so when you click on the first search result it doesnt close the div, but fine on the rest of them. (http://diabli.com/gs/livesearchIFRAMEv3.htm)
Result of what happens (first 2 divs)

Related code:
Code: Select all
// looping through database query setting up the divs in an array
$results[] = "<div id=\"$id\" onClick =\"var qObject = parent.document.getElementById('q'); qObject.value = '$title'; var searchResultObject = parent.document.getElementById('searchResult'); searchResultObject.style.display = 'none';\" onMouseOver=\"this.className='alt2'\" onMouseOut=\"this.className='alt1'\" class=\"alt1\"><b>$title</b>: $description</div>";
// array into one string
$t = implode("\n", $results);
// echo callback function to browser with divs string in
echo "<style type=\"text/css\" media=\"all\"> @import \"../hotjobz/resource/hotjobz.css\"; </style><body onload='window.parent.rpcHandler(\"1\", \"$t\")'>";- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
mm yes, forgot that bit.. well.. if you look at the output, it's error'd though.. watch:(the varialbes are missing)
Do you see all the unescaped quotes?
try this:
[edit] scrap that, it still won't work.. You're mixing both types of strings... That should really be put into a JS function that's not inlined.. or change all the single quote string bits to double quote ones.. (if possible)
Code: Select all
<style type="text/css" media="all"> @import "../hotjobz/resource/hotjobz.css"; </style><body onload='window.parent.rpcHandler("1", "<div id="" onClick
="var qObject = parent.document.getElementById('q'); qObject.value = ''; var searchResultObject = parent.document.getElementById('searchResult'); sea
rchResultObject.style.display = 'none';" onMouseOver="this.className='alt2'" onMouseOut="this.className='alt1'" class="alt1"><b></b>: </div>")'>Do you see all the unescaped quotes?
try this:
Code: Select all
// looping through database query setting up the divs in an array
$results[] = "<div id=\\\"$id\\\" onClick =\\\"var qObject = parent.document.getElementById('q'); qObject.value = '$title'; var searchResultObject = parent.document.getElementById('searchResult'); searchResultObject.style.display = 'none';\\\" onMouseOver=\\\"this.className='alt2'\\\" onMouseOut=\\\"this.className='alt1'\\\" class=\\\"alt1\\\"><b>$title</b>: $description</div>";
// array into one string
$t = implode("\n", $results);
// echo callback function to browser with divs string in
echo "<style type=\"text/css\" media=\"all\"> @import \"../hotjobz/resource/hotjobz.css\"; </style><body onload='window.parent.rpcHandler(\"1\", \"$t\")'>";[edit] scrap that, it still won't work.. You're mixing both types of strings... That should really be put into a JS function that's not inlined.. or change all the single quote string bits to double quote ones.. (if possible)