Results 1 to 6 of 6

Thread: Convert javascript links to html/php links.

  1. #1
    Senior Member agua's Avatar
    Join Date
    Sep 2005
    Location
    Pottsville, NSW
    Posts
    531

    Convert javascript links to html/php links.

    I'm just cleaning up a job for someone and it was built with a javascript jump menu type navigation thing.

    I am making to links back into html - but can't work out the syntax - here is the code on the targetted php file:

    if (!$resSrch) {
    $query = $db->select("select * from rooms order by name");
    $result = '';
    foreach ($query as $c)
    {
    $room.="<option value=".$c[id]." ".($productRoom==$c[id]?'selected':'').">".$c["name"]."</option>";
    }
    How would that look as html?

    Also - would the php file still work if I change the link which calls it into action?
    I Do Website Design - but I am here to learn all about publishing

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,048
    It is hard to say, that isn't the whole story. It is printing out form elements, so we'd need to see the rest of the form and any JS located in the header of the document.
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    Senior Member agua's Avatar
    Join Date
    Sep 2005
    Location
    Pottsville, NSW
    Posts
    531
    Thanks Chris - I'll investigate further
    I Do Website Design - but I am here to learn all about publishing

  4. #4
    Senior Member agua's Avatar
    Join Date
    Sep 2005
    Location
    Pottsville, NSW
    Posts
    531
    OK - I've tried to work this out - and I ain't got a clue... If any of you have got time - could you have a look please

    Here is the php I have singled out:
    if ($search == 1){

    $sql = "select ro.name roname, i.name iname from rooms ro, items i where

    ".($productItems?"i.id = '$productItems' and " : '')."

    ro.id = '$productRoom'";

    $s1 = $db->select($sql);
    $sql="
    select
    distinct p.id as id, p.name as pname, p.code as code, p.price, i.name, ra.name, ro.name, p.pic_preview as ppicpreview
    from
    products as p,
    items as i,
    ranges as ra,
    rooms as ro

    where
    p.item_id = i.id
    and
    p.room_id = ro.id
    and
    p.range_id = ra.id
    and
    ro.id = '$productRoom' and
    p.item_id = '$productItems'
    ";
    // echo $sql;

    $smarty->assign("s1Room",$s1[0]["roname"]);
    $smarty->assign("s1Item",$s1[0]["iname"]);
    Here is the javascript:
    <script language="JavaScript">
    var items_1=new Array (
    '1', 'bookcases',
    '16', 'butler tables',
    '13', 'coffee tables',
    '14', 'hall tables',
    '5', 'leather accents',
    '12', 'mirrors',
    '15', 'side tables',
    '8', 'storage and display units',
    '9', 'tables',
    '10', 'wood accents',
    '');

    var items_2=new Array (
    '1', 'bookcases',
    '11', 'chests of drawers',
    '6', 'sideboards',
    '8', 'storage and display units',
    '');

    var items_3=new Array (
    '1', 'bookcases',
    '2', 'chairs',
    '13', 'coffee tables',
    '14', 'hall tables',
    '6', 'sideboards',
    '8', 'storage and display units',
    '9', 'tables',
    '');

    var items_4=new Array (
    '16', 'butler tables',
    '2', 'chairs',
    '11', 'chests of drawers',
    '13', 'coffee tables',
    '17', 'sectionals',
    '15', 'side tables',
    '7', 'sofas',
    '8', 'storage and display units',
    '');

    var items_5=new Array (
    '3', 'home office and entertainment',
    '');

    var items_6=new Array (
    '11', 'chests of drawers',
    '');

    var items_0=new Array ('');

    function freeSelect(sel,dflt){
    for(var i=0;sel.options.length>0;i++){
    sel.options[0]=null;
    }
    sel.options[0]=new Option(dflt,'');
    }

    function changeRoom(form,room)
    {
    var cb=form.productItems;
    freeSelect(cb,'select item');
    var items=eval("items_" + room);
    for(i=0; i<(items.length-1);i+=2)
    {
    var opt=new Option(items[i+1],items[i]);
    cb.options[cb.options.length]=opt;
    }

    }

    </script>
    Here is the form:
    <form action="searchresults.php" method="post" name=myChoices>
    <table align="left">
    <tr>
    <td width="91" rowspan="4" align="left" valign="top"><img src="/img/join.gif" width="14" height="74" /></td>
    <td width="91" height="25" align="left" valign="top"><select id=select5 name=productRoom onchange="changeRoom(this.form,this.value)">
    <option value="0">quick find</option>
    <option value=1 >Accents</option>
    <option value=2 >Cabinets</option>
    <option value=6 >Chests</option>
    <option value=3 >Dining Room</option>
    <option value=4 >Living Room</option>
    <option value=5 >Multimedia</option>
    </select>
    </td>
    <td width="28">&nbsp;</td>
    </tr>
    <tr>
    <td align="left" valign="top"><div align="center"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif">and</font></div></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="left"><select id=select6 name=productItems>
    <option value="0">select item</option>
    </select>
    </td>
    <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
    <td align="left" valign="top"><input name="Send22" type="image" value="Send"
    src="/img/go.gif" alt="Send" width="28" height="19"
    />
    </td>
    <td>&nbsp;</td>
    </tr>
    </table>
    <input type=hidden name=search value=1 />
    </form>
    I did find a link to the "Print this page" which is this:
    searchresults.php?print&productRoom=6&productItems =11&Send22_x=13&Send22_y=17&Send22=Send&search=1
    - but that doesn't work anyway... so maybe the whole thing doesn't work.

    Much appreciated if you can see anything which my untrained eye can't

    Cheers
    I Do Website Design - but I am here to learn all about publishing

  5. #5
    Registered
    Join Date
    May 2005
    Posts
    81
    I don't see $room being used in the newest code you posted?.. Maybe you can also put an example online (html)

    I agree it seems tricky though

  6. #6
    Senior Member agua's Avatar
    Join Date
    Sep 2005
    Location
    Pottsville, NSW
    Posts
    531
    Thanks for looking polspoel

    I forgot to update this post... the whole job was made using Smarty Templates - and we think the original coder has gone Smarty mad - so I'm just remaking it from scratch - it seems like the best solution and will also be easier for future updates.

    Thanks again
    I Do Website Design - but I am here to learn all about publishing

Similar Threads

  1. Script to turn all links into javascript or redirects
    By Westech in forum Website Programming & Databases
    Replies: 5
    Last Post: 10-20-2014, 04:34 PM
  2. Javascript to change a link's css class
    By Chris in forum HTML, CSS, Layout, and Design
    Replies: 2
    Last Post: 11-18-2006, 02:38 PM
  3. How Do You Use Javascript Links?
    By incka in forum Search Engine Optimization
    Replies: 27
    Last Post: 12-27-2003, 03:28 PM
  4. Javascript Links
    By Mike in forum HTML, CSS, Layout, and Design
    Replies: 19
    Last Post: 12-25-2003, 09:34 AM
  5. Do javascript links still "refer" ?
    By Percept in forum Search Engine Optimization
    Replies: 2
    Last Post: 11-12-2003, 06:03 PM

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
  •