cardfan Posted May 27, 2008 Share Posted May 27, 2008 Having a problem with createTextNode, every area of my document using createTextNode leaves a space on the first line when there is multiple lines of ouput, this leaves the 2nd line out of alignment. ...any ideas? Have no style formatting or anything else that would effect the output Thanks ////////////////////////////////////////////////////////////////////////////// output test test, AK 22222 ///////////////////////////////////////////////////////////////////////////////// Here's a snippet of the code if(streetNum != ""){ strAddress = streetNum +" "+street; } else{ strAddress = street; } //insert text txtNode = document.createTextNode(strAddress); document.getElementById("address").appendChild(txtNode); //add break here var lineBreak = document.createElement("br"); document.getElementById("address").appendChild(lineBreak); if(crossStreet != ""){ strAddress = " & "+crossStreet; //insert text txtNode = document.createTextNode(strAddress); document.getElementById("address").appendChild(txtNode); //add break here var lineBreak = document.createElement("br"); document.getElementById("address").appendChild(lineBreak); } Quote Link to comment Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 It's tough to tell you where your problem is without values for the variables. Can you put together a snippet that I can load into my browser to test? Quote Link to comment Share on other sites More sharing options...
cardfan Posted May 29, 2008 Author Share Posted May 29, 2008 I'm not seeing anything in the assignments that is causing a space, here's the output from php to Javascript vars //populate address info var streetNum = "<?php echo trim($row_results['streetnum']);?>"; var street = "<?php echo trim($row_results['street']);?>"; var crossStreet = "<?php echo trim($row_results['crossstreet']);?>"; var suiteNum = "<?php echo trim($row_results['suitenum']);?>"; var city = "<?php echo trim($row_results['city']);?>"; var state = "<?php echo trim($row_results['state']);?>"; var zip = "<?php echo trim($row_results['zip']);?>"; ************ Here's the page source //populate address info var streetNum = "1025"; var street = "test street"; var crossStreet = "test cross street"; var suiteNum = "205"; var city = "Columbia"; var state = "MO"; var zip = "65203"; ************* here's another sample of the indented output (space before the ampersand is ok, but the space before the 1025 is my issue can not get rid of it) 1025 test street & test cross street Suite Number 205 Columbia, MO 65203 ************* Here's the function function outputAddress(){ var strAddress=""; var txtNode; //txtNode = document.createTextNode(addrTxt); if(streetNum != ""){ strAddress = streetNum +" "+street; } else{ strAddress = street; } //insert text txtNode = document.createTextNode(strAddress); document.getElementById("address").appendChild(txtNode); //add break here var lineBreak = document.createElement("br"); document.getElementById("address").appendChild(lineBreak); if(crossStreet != ""){ strAddress = " & "+crossStreet; //insert text txtNode = document.createTextNode(strAddress); document.getElementById("address").appendChild(txtNode); //add break here var lineBreak = document.createElement("br"); document.getElementById("address").appendChild(lineBreak); } if(suiteNum != ""){ strAddress = "Suite Number "+suiteNum; //insert text txtNode = document.createTextNode(strAddress); document.getElementById("address").appendChild(txtNode); //add break here var lineBreak = document.createElement("br"); document.getElementById("address").appendChild(lineBreak); } strAddress = city + ", " + state +" "+ zip; //insert text txtNode = document.createTextNode(strAddress); document.getElementById("address").appendChild(txtNode); //add break here var lineBreak = document.createElement("br"); document.getElementById("address").appendChild(lineBreak); } Thanks for looking at it rhodesa Quote Link to comment Share on other sites More sharing options...
cardfan Posted May 31, 2008 Author Share Posted May 31, 2008 Found the problem <div style="padding:5px 5px 5px 5px;" class="drkgreencopy" id="address" align="left"> </div> had &nbsb; in my html duh! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.