need help in php or javascript

Discussion in 'Programming' started by Axali, Oct 1, 2011.

  1. #1
    [​IMG]
    <form id="form1" name="form1" method="post" action="">
      <label>
        <select name="select" id="select">
          <option>Category 1</option>
          <option selected="selected">Category 2</option>
          <option>Category 3</option>
        </select>
      </label>
      <br />
    </form>
    <table width="164" border="2" cellspacing="2" cellpadding="2">
      <tr>
        <th width="374" scope="col"><a href="#" class="listennow" onclick="var w=window.open('http://site.com','mywindow','width=366,height=335,top=180,left=450,menubar=no,status=no,directories=no,copyhistory=no,location=no,toolbar=no,scrollbars=no,resizable=yes'); w.focus(); return false; ">category 2 open new windows<br />
        </a></th>
        </tr>
      </table>
    PHP:
    i have this menu list and table. i want when i click category 2 this table replaced category 2 table

    [​IMG]
    in category 2 table i have different codes (javascript and html)

    please help, thanks.
     
    Axali, Oct 1, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    Do you use Jquery? It would make thinks a bit less complicated, although it shouldn't be to difficult in javascript. If you give me a minute.



    <html>
    <head>
    </head>
    <script>
    var selection=1;
    function changeSelect()
    {
    	e=document.getElementById("select");
    	selection=e.options[e.selectedIndex].id;
    	document.getElementById("nr").innerHTML=selection;
    	
    }
    function openWindow()
    {
    	var w=window.open('http://127.0.0.1/?url='+selection,'mywindow','width=366,height=335,top=180,left=450,menubar=no,status=no,directories=no,copyhistory=no,location=no,toolbar=no,scrollbars=no,resizable=yes'); w.focus(); return false;
    }
    </script>
    <body>
    <form id="form1" name="form1" method="post" action="">
      <label>
        <select name="select" id="select" onChange="changeSelect()">
          <option id="1">Category 1</option>
          <option id="2" selected="selected">Category 2</option>
          <option id="3">Category 3</option>
        </select>
      </label>
      <br />
    </form>
    <table width="164" border="2" cellspacing="2" cellpadding="2">
      <tr>
        <th width="374" scope="col"><a href="#" class="listennow" onclick="openWindow()">category <span id="nr">2</span> open new windows<br />
        </a></th>
        </tr>
      </table>
      </body>
      </html>
    Code (markup):
    This should do it
     
    Last edited: Oct 1, 2011
    ssmm987, Oct 1, 2011 IP
  3. Axali

    Axali Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks you but there is different links

    if i choose category 2 i want to show people this
    and if i choose category 3 i need to show people this
    please help
     
    Last edited: Oct 1, 2011
    Axali, Oct 1, 2011 IP