JavaScript - Need To Get Table Row Index
Hi All,
I have this table with a repeat region (this pulls a series of records from my database and displays them in the table). I have a button in one of the table cells that calls a function to delete the current row where the button is pressed (I am trying to pass the row index to the function). Here is what I have which is clearly wrong but I am hoping someone can offer an option that will work. Code: <script type="text/javascript> function deleteRow(tableID,tr) { //alert('tableID is '+tableID+' and rowCount is '+tr); if (document.getElementById(tableID)) { try { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; //alert ("row is "+i); if(i == tr) { table.deleteRow(i); i++; if(rowCount==0){ table.parentNode.removeChild(table); } } } }catch(e) { alert(e); } } } </script> <table id="dataTable" width="100%" border="0"> <?php do { ?> <tr> <td width="33%"><?php echo $row_rstRequestedEquip['EquipNeeded']; ?></td> <td width="33%"><?php echo $row_rstRequestedEquip['Quantity']; ?></td> <td width="33%"><input type="button" name="remove" value="Remove" class="button" onclick = "deleteRow(dataTable,this.rowIndex)" /></td> </tr> <?php } while ($row_rstRequestedEquip = mysql_fetch_assoc($rstRequestedEquip)); ?> </table> Thanks in advance for any help. Kind regards, Ken Similar TutorialsHere is some code i use in one of my functions. I was wondering if the text would be found by google and indexed? (It replaces text with another piece of text and a link) Code: $("#replace").html('<a href="javascript:location.reload(true)">Back Home</a>Apparently, Voynich wanted to have the mysterious manuscript deciphered and provided photographic copies to a number of experts.'); Hi i can't seem to get a drop downs selected index. This is my drop down box: Code: <select name="queba" id="queeba"> <option value="ban1">Bank1 <option value="ban2">Bank2 <option value="ban3">Bank3 <option value="ban4">Bank4 </select> thanks i want to find the index of array through user defined function . my function is. Code: var Month_Label = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); function index() { var p=-1; for(i=0;i<Month_Label.length;i++) { if(Month_Label[i]=="February") { p=i; break; } } alert(p); } but it is not working. any body can help me. what is wrong with my code Hi all.. I have a modal window I'm working on, but the flash below it comes over the top of the modal window. I'm assuming it's a z-index issue. I'm using Tinybox2 for the modal window, and it's CSS styles use 800 and 900 for z-index. Code: .tbox {position:absolute; display:none; padding:14px 17px; z-index:900} .tinner {padding:15px; -moz-border-radius:5px; border-radius:5px; background:#fff url(images/preload.gif) no-repeat 50% 50%; border-right:1px solid #333; border-bottom:1px solid #333} .tmask {position:absolute; display:none; top:0px; left:0px; height:100%; width:100%; background:#000; z-index:800} .tclose {position:absolute; top:0px; right:0px; width:30px; height:30px; cursor:pointer; background:url(images/close.png) no-repeat} .tclose:hover {background-position:0 -30px} The flash itself isn't in a div but in a table. Is there a way to give it a lower z-index? Thanks in advance! carrie I'm not completely sure this is javascript, but is there a way of changing the z-index of my flash object when hovering over it? Here is a link to my page: http://aspspider.org/Samii/HireCar.aspx As you can see, you cannot click on the link in the main content area because the menu is on a higher z-index than the content. I need a way for the content to be on a higher z-index than the menu until the menu is hovered over, in which case the z-index of the menu will be higher. I hope this makes sense. Please help, this is driving me insane! Samii x Hi.. i have a login page and it is separately in my index.php now i need my login page become a pop up form when I open my index.php here is my login.php Code: <?php include 'config.php'; session_start(); //if (isset($_SESSION['logged_in'])) { // header('Location:index.php'); // die(); // } if (isset($_POST['submit'])) { $username=$_POST['username']; $password=($_POST['password']); $sql = "SELECT username, password FROM pay_login WHERE username='$username' AND password='$password'"; $rs = $conn2->Execute($sql); if($rs==1){ $_SESSION['logged_in'] = true; header("location:index.php"); } else { echo "<center>"; echo "Wrong Username or Password"; echo "</center>"; } } $smarty->display('login.tpl'); ?> and here is my index.php Code: <?php session_regenerate_id(true); /*include 'config.php'; if (!isset($_SESSION['empID'])) { $sql = "SELECT EMP_ID FROM PERSONAL"; $recPersonal = $conn->Execute($sql); if (!$recPersonal->BOF) { $recPersonal->MoveFirst(); } session_register('empID'); $_SESSION['empID'] = $recPersonal->fields['EMP_ID']; } */ include 'config.php'; $currentEmpID = $_SESSION['empID']; if (!isset($_SESSION['empID'])) { $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME FROM PERSONAL ORDER BY LNAME ASC"; $recPersonal = $conn->Execute($sql); session_register('empID'); $_SESSION['empID'] = $recPersonal->fields['EMP_ID']; } $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME FROM PERSONAL ORDER BY LNAME ASC"; $recPersonalNav = $conn->GetAll($sql); $smarty->assign('personalAll', $recPersonalNav); // ======================================================================================================================== $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ', FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL WHERE EMP_ID='$currentEmpID'"; $recPersonalHead = $conn->Execute($sql); $fullName = $recPersonalHead->fields["FULLNAME"]; $smarty->assign('empid', $currentEmpID); $smarty->assign('fullname', $fullName); session_write_close(); $smarty->display('header.tpl'); $smarty->display('left.tpl'); $smarty->display('empPayroll.tpl'); $smarty->display('footer.tpl'); exit(); ?> and I found a sample pop up code in internet but this pop needs a button befre it was displayed..I want is it will display when i run my index.php here is the link of sample pop up form http://www.nigraphic.com/blog/java-s...-center-screen Thank you I have three images nested in three divs that I want to change size on mouseover, but since they're each in their own div, I can't effect their z-indexes relative to one another without targeting their parent divs. I thought I'd be able to contain the images in an <a> tag with z-index style in a mouseover, but I can get it to work. What am I doing wrong here? CSS: Code: .thumb img{ height: 75px; } .thumb img:hover{ height: 150px; } JS: Code: function thmbOver(){ this.style.zIndex = "1000"; } HTML: Code: <div id="div1"><a onmouseover='thmbOver();'><span class='thumb'><img src='thmbs/image1.jpg'></span></a></div> <div id="div2"><a onmouseover='thmbOver();'><span class='thumb'><img src='thmbs/image2.jpg'></span></a></div> <div id="div3"><a onmouseover='thmbOver();'><span class='thumb'><img src='thmbs/image3.jpg'></span></a></div> I've tried a few approaches to the function's targeting, like document.getElementById(this.parent.id).style.zIndex, etc, but still nothing. Any ideas? Thanks, ~gyz I am trying to "swap" the contents of a div(#right_top) depending on which line item you hover over. Awkward, but does work, but.... the problem is that although I can get the code to work, the "right_top" div gets longer (physically on the page) even though each div is supposed to be a different "z-index". I don't know how to correct this, or is there better code? I would appreciate any help! Thank you. Complete code below..... ------------------------------------------------------------------- Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <script language="javascript" type="text/javascript"> <!-- Hide script from older browsers function MM_findObj(n, d) { //v4.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && document.getElementById) x=document.getElementById(n); return x; } function MM_showHideLayers() { //v3.0 var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; } obj.visibility=v; } } //--> </script> <!-------------------------------------------------------------> <style type="text/css"> #wrapper{ width:800px; } #left_top{ background-color:#66FFFF; width:270px; padding-top:60px; padding-left:30px; float:left; } #right_top{ background-color:#66FF33; padding-top:60px; width:480px; padding-left:20px; float:left; } #first_div{ position:relative; width:450px; height:300px; z-index:1; visibility: hidden; left:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; color:#FFFFFF; } #second_div{ position:relative; font-size:16px; width:450px; height:300px; z-index:2; top: -320px; visibility: hidden; left:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; color:#FFFFFF; } #third_div{ position:relative; font-size:16px; width:450px; height:300px; z-index:3; top: -640px; visibility: hidden; left:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; color:#FFFFFF; } </style> </head> <body> <div id="wrapper"> <div id="left_top"> <table width="210" height="483"> <tr><td width="210" height="477" valign="top"> <div><a title="first div" href="#" class="style1" onClick="return false" onMouseOver="MM_showHideLayers('Initial','','hide','first_div','','show')" onMouseOut="MM_showHideLayers('Initial','','show','first_div','','hide')">show first div</a></div> <div><a title="second div" href="#" class="style1" onClick="return false" onMouseOver="MM_showHideLayers('Initial','','hide','second_div','','show')" onMouseOut="MM_showHideLayers('Initial','','show','second_div','','hide')">show second div</a></div> <div><a title="third div" href="#" class="style1" onClick="return false" onMouseOver="MM_showHideLayers('Initial','','hide','third_div','','show')" onMouseOut="MM_showHideLayers('Initial','','show','third_div','','hide')">show third div</a></div> </td></tr> </table> </div><!-- end of left_top --> <div id="right_top"> <div id="first_div"> <p align="justify"><b>first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first </b></p></div> <div id="second_div"> <p align="justify"><b>second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second </b></p></div> <div id="third_div"> <p align="justify"><b>third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third </b></p></div> </div><!-- end of right_top div --> </div><!-- end of wrapper --> </body> </html> Javascript I have 3 combolist fields ( A, B and C ) each of which has just "No" and "Confirmed" as their only options. I have one final combolist ( D ) which has just "Yes" and "No" as options. "No" is the default selected item and Index0 in the list. The user must select "Confirm" all three ( A, B and C ) lists before they should be allowed to select "Yes" in the final list ( D ). I want to be able to have the system to automatically select and display "No" in list ( D ) if any of the first 3 selections ( A, B or C ) are "No". I don't have a problem validating if any of the 3 lists ( A, B or C ) are "No" but I cannot get the final combolist to change from "Yes" ( if previously selected ) to "No". I have tried setting the selected index of (D) to 0 and tried setting the selected value of (D) to "No" but if (D) currently displays "Yes" when any of the ( A, B or C ) are changed to "No" nothing happens to (D). Am I trying to do something that cannot be done ? Any help will be gratefully received. Tony Hello I have the code below and I am trying to add another index id to be checked to the two that I already have. I have tried changing the line: var anotherTab = (indx.indexOf('a') >= 0) ? id + 'b' : id + 'a'; to var anotherTab = (indx.indexOf('a') >= 0) ? id + 'b' : id + 'a' : id + 'c'; but I just get a javascript error what would be the correct syntax for a third index id? Code: var groupId=obj.id.substring(0, 1); var indx=obj.id.substring(obj.id.indexOf('_')+1); var id=indx.substring(0, indx.length-1); var anotherTab = (indx.indexOf('a') >= 0) ? id + 'b' : id + 'a'; document.getElementById(groupId+'tab_' + indx).className = 'selected'; document.getElementById(groupId+'tab_' + anotherTab).className = ''; if (indx==id+'a') { show (groupId+'baseballInfo_'+id); hide (groupId+'footballInfo_'+id); hide (groupId+'soccerInfo_'+id); } else if (if (indx==id+'a') { hide (groupId+'baseballInfo_'+id); show (groupId+'footballInfo_'+id); hide (groupId+'soccerInfo_'+id); } else { hide(groupId+'baseballInfo_'+id); hide (groupId+'footballInfo_'+id); show(groupId+'soccerInfo_'+id); } OK so say I have something like this: <TD> <p>Item A</p> <p>Item B</p> <p>Item C</p> <p>Item D</p> </TD> So TD would be the parent and all of the <P>'s would be childNodes. I want to be able to click on each child and have it alert me its index # relative to the parent node. So 'Item A' should alert "0", 'Item B' - "1", 'Item C' - "2", etc. Thanks in advance. Just to let you know if you don't know how to do this is the code I use: It will solve the problem of the clip scrolling over text etc. <embed wmode="transparent" src="youtube URL" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="280" height="240"></embed> (mods, do with this as you please). Hi, I'm trying to select check boxes with particular values, unfortunately it is not a very well structured page at all which has left me clueless as to how to go about doing this, I'll show the page code and let you know what it is that I'm trying to do and hopefully somebody will be able to come up with a method of doing this! Full page code can be seen he http://pastebin.com/kBWqvXe3 Partial code: Code: // Partial code, full code at: http://pastebin.com/kBWqvXe3 <form action="itemtransfer.php" method="post"> <table width="760" height="399"> <tr> <td width="579" bgcolor="#000000" valign="top" style="border:2px inset;"> <table> <tr> <td align="center" valign="bottom"> <img border="0" width="43" height="43" src="http://sitename/images/items/item_allseeingeye.jpg" ONMOUSEOVER="itempopup(event,616210549)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="616210549"></center> </td> <td align="center" valign="bottom"> <img border="0" width="43" height="43" src="http://sitename/images/items/item_allseeingeye.jpg" ONMOUSEOVER="itempopup(event,616337548)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="616337548"></center> </td> <td align="center" valign="bottom"> <img border="0" width="43" height="43" src="http://sitename/images/items/item_allseeingeye.jpg" ONMOUSEOVER="itempopup(event,616023597)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="616023597"></center> </td> <td align="center" valign="bottom"> <img border="0" width="50" height="50" src="http://sitename/images/items/coes_animatedbook.gif" ONMOUSEOVER="itempopup(event,615394126)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="615394126"></center> </td> <td align="center" valign="bottom"> <img border="0" width="49" height="50" src="http://sitename/images/potion_yellow.gif" ONMOUSEOVER="itempopup(event,575558221)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="575558221"></center> </td> <td align="center" valign="bottom"> <img border="0" width="40" height="40" src="http://sitename/images/items/Aslan-Magic.jpg" ONMOUSEOVER="itempopup(event,615238517)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="615238517"></center> <td align="center" valign="bottom"> <img border="0" width="41" height="50" src="http://sitename/images/unique945.gif" ONMOUSEOVER="itempopup(event,616680604)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="616680604"></center> </td> <td align="center" valign="bottom"> <img border="0" width="43" height="43" src="http://sitename/images/items/item_zhulianpowershard.jpg" ONMOUSEOVER="itempopup(event,616672188)"; ONMOUSEOUT="kill()"><br/><center><input type="checkbox" name="checkbox[]" value="616672188"></center> </td> </tr> </table> </td> <td width="282" bordercolor="#000000" bgcolor="#666666" style="border:2px inset;" valign="top"><p>To send an item to another one of your characters, check the items off you would like to send on the left. Then, use the form below to tell us who you want the items to go to!</p> <p> <b>Items not included: </b><br /> <ul style="margin-top: -5px;"> <li>Equipped Items</li> <li>Player Bound Items</li> <li>Items in your vault</li> <li>Items on the tradeblock</li> </ul> </p> <p> <form action="itemtransfer.php" method="GET"> <input type="checkbox" name="includePlayerbound" value="1" onClick="javascript: document.location.href='http://sitename/itemtransfer.php?includePlayerbound=' + this.value;" /> <strong>Include Playerbound Items<br /><br />500 Points Per Godly Protection Set Item<br />200 Points Per Celestial Set Item<br />100 Points Per Oblivion Set Item<br />100 Points Per Sovereign Set Item<br />25 Points Per Other Playerbound Items</strong> </form> </p> <p><strong>Send to your character (lvl 10+):</strong><br/> <select name="self"> <option value="0">Select a Character</option> <option value="786786">B1LLY</option> </select> </p> <p> <input type="submit" name="submit" value="Send items!"> </p> </td> </tr> </table> </form> </td> </tr> </table> <p align="center"><font size="1"> <a href="/home.php">HOME</a> | <a href="/world.php">EXPLORE</a> | <a href="/treasury.php?type=55">TREASURY</a> | <a rel="nofollow" target="_New" href="http://wiki.***********">HELP</a> <!-- | <a href="/world.php?fbapp=1">SMALL SCREEN</a> --> </font><p align="center"> <font size="1"> <a href="/privacy.php">Privacy Policy</a> | </font><b> <!-- <font size="1"> <a href="/spampolicy.php">Anti-Spam Policy</a></font></b><font size="1"> | </font><b> <font size="1"> <a href="/antifraud.php">Anti-Fraud Policy</a></font></b><font size="1"> | </font><b> --> <font size="1"> <a href="/outwar_tos.php" rel="nofollow" target="_blank">Terms of Service</a></font> <br> srv 147 Page was generated in 3.044907 seconds</font></center> </div> </div> </center> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-16031817-1"); pageTracker._setDomainName(".***********"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html> What I'm trying to do is to check the boxes that are the 'item' named item_allseeingeye.jpg each image corresponds to a checkbox so I thought I could make an array to loop through all images and an array to loop through each of the checkboxes to get a matching index so I can check the checkbox. If anyone knows a better way of doing this I would really appreciate the help! Many thanks, David. hi, lets say I have two arrays . The first array has names of fruits and the second array has numbers(1-5) what Iam after is that I try to print fruits names and attach an index number for each ..such as: arr_fruit("apple","melon","banana","grape","...") arr_index(1-5) output should look like... 1-apple 2 apple 3 apple, 4 apple 5 apple 1 melon 2 melon 3melon 4melon 5 melon 1 banana 2 banana ..... ....... so I think ı need a "for looping" and to achieve this but can not figure it out.. thanks. I am now working on a utility function that will gather the indexes for substring matches found in a string. There is an academic mystery I am puzzling over Code: function getMatchIndex(a, b) // a: sting to search b: what to search for { var out = new Array(); if(a.lastIndexOf(b) > -1) // at least two matches, ****! there could be more { if( (a.substr(a.indexOf(b) + b.length, a.lastIndexOf(b))).length > b.length ) { var stp = parseInt(a.lastIndexOf(b)) - (parseInt(a.indexOf(b)) + parseInt(b.length)); alert(stp) alert( (a.substr(a.indexOf(b) + b.length, stp)).length+' : '+a.substr(a.indexOf(b) + b.length, stp)); } else { out[out.length] = a.indexOf(b); out[out.length] = a.lastIndexOf(b); return out; } } else if(a.indexOf(b) > - 1 && a.lastIndexOf(b) == -1) { out[out.length] = a.indexOf(b); return out; } else if(a.indexOf(b) == -1) { out = 'no matches'; return out; } else { var splitStr = new Array(); splitStr = a.split(b); /* possibilities: 1: one match at the begining or end -- leaves one significant item 2: one match somewhere after the beginning and before the end. -- gives two matches. */ for(var i = 0; i < splitStr.length - 1; i++) // don't want the last segment length { out[out.length] = splitStr[i].length } } } getMatchIndex('xxxi5ixxxxxxxi5ixx', 'i5i'); in the following code snippet: Code: if( (a.substr(a.indexOf(b) + b.length, a.lastIndexOf(b))).length > b.length ) { var stp = parseInt(a.lastIndexOf(b)) - (parseInt(a.indexOf(b)) + parseInt(b.length)); alert(stp) alert( (a.substr(a.indexOf(b) + b.length, stp)).length+' : '+a.substr(a.indexOf(b) + b.length, stp)); I am trying to get the sub string between the end of the first match to the beginning of the last match. The 'if' test passes, but I have to parseInt the values to get the proper value for stp. SO, the question is, what is the actual data type of an index value obtained from a string. (It would appear to be a string; having to use it an a math expression doesn't work without parseInt). (I hope I haven't posted too much code) Thank you in advance. How do I use array.push to add an object with a custom index in an array? I have this script but it doesnt work. Chrome's Javascript console is not outputting errors Code: var tempList = new Array(); $('#add').click(function(){ var split = $('#itemid').val().split('_'); var itemid = split['0']; var lbs = $('#lbs').val(); tempList.push(tempList['itemid'] = lbs); for (var i=0; i<=(tempList.length - 1); i++){ if (i==0){ var list = tempList[i]+ '<br />'; } else{ var list = list + tempList[i]+ '<br />'; } } alert(list); }); So I am working on a function that counts the number of lines a user input takes up. I'm accounting for a line being 114 characters long, and I am trying to account for returns which in some cases are used for a blank line, and in others simply to proceed to a new line for new text. But thats not important really. I am having problems identifying the returns from my form submit. The code below isnt identifying them, I get that. But when I google this issue, it tells me to do something like hard = biotext.indexOf("\r"); Instead of the <br /> which I also understand. Unfortunately, as soon as I do that, my javascript completely breaks and stops working, as though I had a major syntax error. I dont understand as this syntax is suggested in many sites on the net. Code: function count_bio(ctl, ev) { var biotext = ctl.value; var counter = 0; hard = biotext.indexOf("<br />"); hardx = hard; while(hard > 0) { hard=hardx-y; if(hard > 114){counter+=Math.ceil(hard/114);} else{counter+=1;} y=hardx; hardx=biotext.indexOf("<br />", hardx+1); } if(counter==0) { counter=Math.ceil(biotext.length / 114); } else { if(hardx > 114){counter+=Math.ceil(hardx/114);} else{counter+=1;} } alert(counter); return true; } Hi, I am very new to Javascript but have found a great tutorial to create a dynamic dropdown menu. I got it to work, but have problems redirecting it to the correct page after the necessary page refresh to load the items in the 2nd dropdown menu. The Javascript in the header is the following: Code: <SCRIPT language=JavaScript> function reload(form){ var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='index.php?cat=' + val ;} </script> My PHP controller (index.php) code to load the correct frames is as follows: Code: <ul id="navbar"> <li><a href="index.php?id=home">Home</a></li> <li><a href="index.php?id=overview">Overview</a></li> <li><a href="index.php?id=add">Add new product</a></li> </ul> Code: if(isset($_GET['cat'])){ include ('add.html.php');} else { switch($_GET['id']) { default: include('home.html.php'); break; case "home": include('home.html.php'); break; case "overview": include('add.html.php'); break; case "add": include('add.html.php'); } } So I have made a workaround to load the "add.html.php" frame with the if(isset)$_GET['cat']. But what I really would like to do is to change the Javascript self.location to Code: self.location='index.php?id=add?cat=' + val ;} so that the PHP index script loads the add.html.php automatically. However, when changing the self.location as described above the page is redirected to home.html.php. It is really annoying, I have googled for a full day but haven't found a solution yet. Maybe someone can tell me how I can easily load the correct frame by using Javascript? Many thanks in advance!! Hello im making a search program and the results are displayed in HTML, i decided i wanted a link after each line in an innerHTML div, the problem is i cant set the id dynamicly i have the class is to style. .innerHTML = "<a id = 'myarray[arraycounter]' class = 'innerLink' href = 'javascript:'>View camp information</a>" but this dosent work. i also tried using " thinking that it was because it needed double quotes but this still didnt work. when i inspect the element in chrome it just comes up as array[value]. please help me out guys i need a way to dynamicly give it a link. |