Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Question problem with elements and childs

    when I use this script instead all the images be in one row they are in three rows.
    here's a part of my script:
    Code:
    var voteDiv = document.createElement('DIV');
    
    voteDiv.className='result_pollGraph';
    
    resultDiv.appendChild(voteDiv);	
    
    
    
    var leftImage = document.createElement('IMG');
    
    leftImage.src = voteLeftImage;
    
    voteDiv.appendChild(leftImage);
    
    
    
    
    
    var numberDiv = document.createElement('DIV');
    
    numberDiv.style.backgroundImage = 'url(\'' + voteCenterImage + '\')';
    
    numberDiv.innerHTML = '0%';
    
    numberDiv.id = 'result_voteTxt' + currentOptionId;
    
    voteDiv.appendChild(numberDiv);	
    
    
    
    var rightImage = document.createElement('IMG');
    
    rightImage.src = voteRightImage;
    
    voteDiv.appendChild(rightImage);
    here's a link for who doesn't understand my explanation:
    http://neostar.110mb.com/polls/ajax-poller.php

    thanks.
    Last edited by shedokan; 12-31-2007 at 01:21 AM.

  • #2
    New Coder
    Join Date
    Jun 2005
    Posts
    52
    Thanks
    0
    Thanked 4 Times in 4 Posts
    I think IMG tags are block level elements...

    You can try looking into this CSS rule...

    Code:
    .result_pollGraph img { display: span }

  • #3
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts
    didn't change anything.

  • #4
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by Zefris View Post
    I think IMG tags are block level elements...

    You can try looking into this CSS rule...

    Code:
    .result_pollGraph img { display: span }
    No such value listed. Try styling all divs display:inline

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by Zefris View Post
    I think IMG tags are block level elements...
    Nope, inline.

  • #6
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Question

    thanks now the only problem left is that all of the percent's have equal width.
    here is the script:
    Code:
    function slideVotes(pollId,currentPercent)
    
    {
    
    currentPercent = currentPercent/1 + 1;
    
    	
    
    for(var prop in pollVotes[pollId]){
    
    	if(pollVotes[pollId][prop]>=currentPercent){
    
    		var obj = document.getElementById('result_voteTxt' + prop);
    
    		obj.innerHTML = currentPercent + '%';
    
    		obj.style.width = Math.max(graphMinWidth,Math.round(currentPercent/100*graphMaxWidth)) + 'px';
    
    	}			
    
    }
    
    
    
    if(currentPercent<100)setTimeout('slideVotes("' + pollId + '","' + currentPercent + '")',pollScrollSpeed);
    
    }
    and the function is called like this:
    Code:
    slideVotes(pollId,0);

  • #7
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Code:
    obj.style.width = Math.max(graphMinWidth,Math.round(currentPercent/100*graphMaxWidth)) + 'px';
    If I understand what you're trying to do, maybe this expression would work:
    Code:
    obj.style.width = Math.round(currentPercent/100*(graphMaxWidth-graphMinWidth)) + 'px';

  • #8
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts
    nope, still equal width.

  • #9
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts
    *Bump*

  • #10
    Regular Coder
    Join Date
    Oct 2007
    Posts
    277
    Thanks
    2
    Thanked 4 Times in 4 Posts
    actually that helped but the ffour top ones are equal and the last one is ok.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •