SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    put results from displayed in rows or columns

    Hi i have the a drop down list that depending on the user selection display the list of results
    for example if (select color) display (red, blue, pink)
    if select car display(ford,bentley,ferrari) and so on
    but now i am trying to put the result in a table each element to their own or column.
    this my code can easy be run on w3school site
    can someone help me please
    thanks in advance

    Code:
    <HTML>
    <HEAD>
    <SCRIPT TYPE="TEXT/JAVASCRIPT">
    function setup(ans) {
      lit = ''
      if (ans == 'color') {
    
        lit = lit + '<br/>blue<br/>'
        lit = lit + '<br/>red<br/>'
        lit = lit + '<br/>green<br/>'
        lit = lit + '<br/>pink<br/>'
        lit = lit + '<br/>yellow<br/>'
      }
      if (ans == 'number') {
        lit = lit + '<br/>one<br/>'
        lit = lit + '<br/>two<br/>'
        lit = lit + '<br/>three<br/>'
        lit = lit + '<br/>four<br/>'
        lit = lit + '<br/>five<br/>'
    
      }
    
    
     if (ans == 'car') {
        lit = lit + '<br/>ferrari<br/>'  
        lit = lit + '<br/>bentley<br/>'
        lit = lit + '<br/>ford<br/>'
        lit = lit + '<br/>mustang<br/>'
    
      }
      document.getElementById('rep').innerHTML=lit
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    
    <FORM ACTION="#" NAME="quest">
    <SELECT NAME="q1" ONCHANGE="setup(document.quest.q1.value)">
    <OPTION VALUE="">- Please select -</OPTION>
    <OPTION VALUE="color">Color</OPTION>
    <OPTION VALUE="number">Number</OPTION>
    <OPTION VALUE="cars">Cars</OPTION>
    </SELECT>
    
    <SPAN ID="rep"></SPAN>
    
    </FORM>
    
    </BODY>
    </HTML>

  2. #2
    SitePoint Member
    Join Date
    Jul 2011
    Location
    Mumbai,India
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hope, this helps.
    Code:
    <HTML>
    <HEAD>
    <SCRIPT TYPE="TEXT/JAVASCRIPT">
    function setup(ans) {
      lit = ''
      if (ans == 'color') {
    
        lit = lit + '<td>blue</td>'
        lit = lit + '<td>red</td>'
        lit = lit + '<td>green</td>'
        lit = lit + '<td>pink</td>'
        lit = lit + '<td>yellow</td>'
      }
      if (ans == 'number') {
        lit = lit + '<td>one</td>'
        lit = lit + '<td>two</td>'
        lit = lit + '<td>three</td>'
        lit = lit + '<td>four</td>'
        lit = lit + '<td>five</td>'
    
      }
    
    
       if (ans == 'car') {
        lit = lit + '<td>ferrari</td>'  
        lit = lit + '<td>bentley</td>'
        lit = lit + '<td>ford</td>'
        lit = lit + '<td>mustang</td>'
      }
      document.getElementById('rep').innerHTML=lit
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    
    <FORM ACTION="#" NAME="quest">
    <SELECT NAME="q1" ONCHANGE="setup(document.quest.q1.value)">
    <OPTION VALUE="">- Please select -</OPTION>
    <OPTION VALUE="color">Color</OPTION>
    <OPTION VALUE="number">Number</OPTION>
    <OPTION VALUE="cars">Cars</OPTION>
    </SELECT>
    
    <table border=1>
    <tr id="rep">
    </tr>
    </table>
    
    </FORM>
    
    </BODY>
    </HTML>

  3. #3
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    perfect senidaljeet thank you very much

  4. #4
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi again i've got two faults with this form 1 when i put the form on my page and try to select the very first option color it doesnt open it only opens when select the other ones and then go bk to the first one. fi you refresh and try to select the color one it wont wont you have to select the other one before you can select the color is just oding on my pc or is it doing on somenone else pc help please

    2nd problem tr not showing on chrome why?
    this how my table looking now

    <SCRIPT TYPE="TEXT/JAVASCRIPT">
    function setup(ans) {
    lit = ''
    if (ans == 'color') {

    lit = lit + '<tr bgcolor="orange"><td>blue sdrtgrtgr</td></tr>'
    lit = lit + '<tr bgcolor="orange"><td>red</td></tr>'
    lit = lit + '<tr bgcolor="#FF0000"><td>green</td></tr>'
    lit = lit + '<tr bgcolor="#FF0000"><td>pink</td></tr>'
    lit = lit + '<tr bgcolor="#FF0000"><td>yellow</td></tr>'
    }
    if (ans == 'number') {
    lit = lit + '<tr bgcolor="orange"><td>one</td></tr>'
    lit = lit + '<tr><td>two</td></tr>'
    lit = lit + '<tr><td>three</td></tr>'
    lit = lit + '<tr><td>four</td></tr>'
    lit = lit + '<tr><td>five</td></tr>'

    }


    if (ans == 'cars') {
    lit= lit + '<tr><td>ferrari</td></tr>'
    lit= lit + '<tr><td>bentley</td></tr>'
    lit= lit + '<tr><td>ford</td></tr>'
    lit= lit + '<tr><td>mustang</td></tr>'
    }
    document.getElementById('rep').innerHTML=lit
    }
    </SCRIPT>

    FORM ACTION="#" NAME="quest">
    <SELECT NAME="q1" ONCHANGE="setup(document.quest.q1.value)">
    <OPTION VALUE="">- Please select -</OPTION>
    <OPTION VALUE="color">Color</OPTION>
    <OPTION VALUE="number">Number</OPTION>
    <OPTION VALUE="cars">Cars</OPTION>
    </SELECT>

    <table >
    <tr id="rep">

    </tr>
    </table>
    </FORM>

  5. #5
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi again i'm having the following issue on that call function
    when i try to insert
    a link to call a jw video
    Code:
     lit = lit + '<a href="#" onClick="jwplayer().load({'file': 'hofbell30732_SD.mp4', 'hd.file': 'videos/film.mp4'})">    javascript video with hd file not working</a>'
    the drop down function stops working i suspect it might be either cz of the semicolons or something but i'm not sure can someone help me out please?

  6. #6
    SitePoint Addict
    Join Date
    Apr 2010
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i manage to get the drop down list to display the results again as it seems had to make single quotes(') into double quotes (") inside the curly brackets but now the link doesnt work how can i allow single quotes or make the link work again
    this how the kink works outside the function with single (')
    Code:
    <a href="#" onClick="jwplayer().load({'file': 'hofbell30732_SD.mp4', 'hd.file': 'videos/film.mp4'})'>    javascript video with hd file not working</a>
    now inside the function had to change the quotes to double quotes inside the curly brackets
    Code:
    <a href="#" onClick="jwplayer().load({'file': 'hofbell30732_SD.mp4', 'hd.file': 'videos/film.mp4'})'>    javascript video with hd file not working</a>
    but the link doesnt work with double quotes
    how can i get it to work insid ethe function

  7. #7
    SitePoint Member
    Join Date
    Jul 2011
    Location
    Mumbai,India
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but the link doesnt work with double quotes
    how can i get it to work insid ethe function
    jw player has its own set of functions and parameters.Need to know, how they are set.could you help with its documentation ?


Bookmarks

Posting Permissions

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