JavaScript - Moving Checkbox+data At Table On Click
hellow,
i try to make a script that gets data from my mysql-database and displays it in a form with check boxes. if i select one or more check boxes the data with its checkbox should move to another column in the table in this form. all the other data and there checkboxes not selected should stay at its own place. in the future i want to work with 150 checkboxes. the part for getting it out off the database and display it in the form with the checkboxes is completed in PHP. but i'm stuck changing its place with the onclick handler from javascript. here you can see it working (but it's written when you click auto1 an click submit all the checkboxes change place and are selected) http://silent.comxa.com/m.php the code i have so far is: PHP Code: <? $ch11 = ''; $ch11 = $_POST['auto1']; $checked = isset($_POST['submit1']) && $_POST['auto1'] == 'on' ? 'checked="checked"' : ''; ?> </head> <body> <? @$cat=$_GET['cat']; if(strlen($cat) > 0 and !is_numeric($cat)){ echo "Data Error"; exit; } ///////// Getting the data from Mysql table ////////// $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category"); ?> <form method="post" name="f2" action="m.php"><table width="828" border="1"> <?php while($noticia2 = mysql_fetch_array($quer2)) { if ($ch11 =='on'){ echo '<tr><td width="200" > </td><td width="300" > </td> <td width="200" > <input name="'.$noticia2[category].'" type="checkbox"'.$checked.'/> '.$noticia2[category].' </td><td width="100">'.$noticia2[cat_id].'</td></tr>'; } else { echo '<tr><td width="200" > <input name="'.$noticia2[category].'" type="checkbox"'.$checked.'/> '.$noticia2[category].' </td><td width="300" >'.$noticia2[cat_id].'</td><td width="200" > </td><td width="100" > </td></tr>';} } ?> </table> <?php echo '<input type="submit" name = "submit1" value="Submit"/>'; echo '</form>'; ?> Similar Tutorialshave a div & a grid i want the div to be displayed on the column header click & be positioned with the specific column suppose 3rd grid header column is clicked the div shld be positioned near 3 column Hi, here is what I am trying to do, mind if I sound simple this is my first major javascript attempt. You click the checkbox and it changes a link. You click the checkbox again and it changes it back. So you have a page with a link : <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN" id="pay"><img src="go.gif"></a> and a checkbox : <a nohref style="cursorointer;color:blue;text-decoration:underline" onclick="changeTarget()"><input type="checkbox" OnClick="changeTarget()" checked="yes" name="opt-in" id="opt-in" align="center" /></a> </p> Clicking the checkbox runs the javascript function ChangeTarget(). Here is what I want the javascript to do: Code: 1. Write current pay value to variable 2. Compare variable to paypal link -3. change to clickbank link -else change to paypal link. Here is the code I have tried that doesnt work: Code: <script type="text/javascript"> var link = document.getElementById('pay'); function changeTarget() if(link == "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN") document.getElementById('pay').href="http://1.60years.pay.clickbank.net"; else document.getElementById('pay').href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RSNVHTY5D6RN"; </script> Any help would be very much appreciated, I don't know why it isnt working. It just doesnt do anything when you click it. I know the following DOES work, but it only changes the link to the value chosen... no way of changing it back when you click the checkbox a second time. Code: //WORKING CODE <script type="text/javascript"> function changeTarget() { document.getElementById('pay').href="http://1.60years.pay.clickbank.net"; } </script> I have 2 DIVs on a page, Div1 and Div2. I want to copy the contents from Div1 into Div2, then suppress the contents of Div1. I want to do this when the page loads. This is what I did: Code: <div id="Div1" style="color:red;">This is the text to be moved</div> <div id="Div2" style="color:green;"></div> <script type="text/javascript"> function swapIt() { document.getElementById('Div2').innerHTML = document.getElementById('Div1').innerHTML; document.getElementByID('Div1').style.display = "none"; } onload = swapIt(); </script> This, of course, does not work, but I don't know javascript well enough to figure out why. Could someone give me an example of what would work in this case? Hello everyone. I want to move my image through table cells by using arrow buttons. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Move</title> <style type="text/css" > table { background-color:#FFCC00; margin-top: 100px; margin-bottom: 100px; } </style> </head> <body onload="setup()"> <script type="text/JavaScript" onkeydown="handleKey(event)"> document.write('<table border="1" cellspacing="0" cellpadding="10">'); var count =0 for (var row=0; row<20; row++) { document.write('<tr>'); for (var col=0; col<20; col++) { idnmr = count count++ document.write('<td style="border:0"; id="idnmr";>'); document.write('</td>'); } document.write('</tr>'); } function setup() { row=0; col=0; insertKnight(row,col); } function handleKey(e) { if (typeof e !='object') e=window.event; if (e.type == 'keydown' && (e.keyCode ==27 || (e.keyCode >= 37 && e.keyCode <=40))) { switch (e.keycode) { case 37: dC= -1; dR = 0; break; case 38: dC= +1; dR=0; break; case 39: dC = 0; dR = +1; break; case 40: dC= 0; dR=-1; break; } emptyCell(row,col); function emptyCell(row,col) { var id = 'r' + row + 'c' + col; var cell= document.getElementById(id); if(cell) cell,innerHTML=''; } row +=dR; col +=dC; //insert image insertKnight(row,col); return false; function insertKnight(row,col) { var id = 'r' + row + 'c' + col; var cell = document.getElementById(id); var colour = cell.className; if (colour != 'white') { var knight='cherry.png'; } else { var knight= 'cherry.png'; function eraseImage(row,col) { var id = 'r' + row + 'c' + col; document.getElementById(id).innerHTML = ''; } cell.innerHTML = '<img src=" ' + knight + ' " alt="' + colour + 'knight" />'; } document.getElementById('debug').innerHTML = 'r='+row+' c='+col; function drawImage(row,col) { var id = 'r' + row + 'c' + col; document.getElementById(id).innerHTML = '<img src="cherry.png"/>'; } </script> </body> </html> This is my code. Now i have problems with the eraseImage and drawImage functions. They just don't work. Any help will be appreciated. Thank you I am trying to select multiple <tr>'s (onclick) in a <table> and then move every selected <tr> to another location in the table (on click). I will also be adding functionality to delete specific rows from a table by clicking on a <td> element, though I've already done this by doing. document.getElementById("container").deleteRow(row.parentNode.rowIndex); I am just completely unsure of how to tackle storing each selected row -- and then moving each selected row elsewhere in the table. I've seen many examples that accomplish close to what I am trying to acheive, however, they are all done via drag and drop and do not allow selecting multiple rows. Hello, I'm very new to JavaScript as well as this forum, so apologies if I mess up somewhere. Okay, so I have a HTML doc with a JavaScript attached to it, and in the HTML I have a checkbox. All I want to do is to pass the checkbox data to Javascript as a true/false. Okay, so below is my HTML: Code: <head> <script type="text/javascript" src="java.js"></script> </head> <body> <input id="toggle" type="checkbox" value=""> </body> And this is my JS: Code: var toggleData = false; Now where do I go from here? I tried using getElementByld('toggle'); But no result. I sure would appetite some help here. Thanks First of all Thank you for looking at my issues. Just so you know, I am not a coder I have a new set of problems I'm hoping someone can help me with. Please read all three problems listed below as they are all intertwined. Thank you for any assistance you have with these issues. First, here is the url to my test form http://www.rocpinions.com/test-main-form.html Next, Here is the code I am using. The code is set up on dog cat other and none. The test check 1 etc are all individual check box groups Code: <script type="text/javascript"> function checkI() { var other=0; var checkL = document.getElementsByName('form[PetsInHouse][]'); for (var i=0;i<checkL.length-1;i++){ if(document.getElementById('PetsInHouse3').checked){ document.getElementById('PetsInHouse'+i).disabled = true; document.getElementById('PetsInHouse'+i).checked = false; } else { document.getElementById('PetsInHouse'+i).disabled = false; } if(document.getElementById('PetsInHouse'+i).checked){ other++ } } document.getElementById('PetsInHouse3').disabled=other>0?true:false; } </script> And here is the call I am using onclick="checkI();" Problem 1 This code works fine as is is set up and does what it should. The problem is i am also using this on longer sets of check boxes and I would like to instead of disabling I would like to have it set up so if someone clicks dog cat and other then if they choose the check box "None" it would empty all other check boxes and check the check box "None" and visa versa if none was checked and they checked dog, it would empty the None check. Problem 2 I am using Joomla cms and a form constructor called RS Form Pro. It stores the data submitted in the form to a data base. As it is now, all the info in the check box group is submitted to ONE column. I need to submit it to individual columns for each choice. I can accomplish this by using individual check box groups for EACH item. This will put it in separate columns in the data base but I still need to have it set up so if someone clicks dog cat and other then if they choose the check box "None" it would empty all other check boxes and check the check box "None" and visa versa if none was checked and they checked dog, it would empty the None check. Problem 3 How it submits data to the data base Right now, it submits the data from the check boxes by the name of the check box. What I would like to have is a 1 if it IS checked and a 0 if IS NOT checked. Again, Thank you for any assistance DeZiner hi i am doing a project and now i am try to work on paging, however i am stuck. I want to put in a list of links of website in the itemfilereadstore. So when show, i want to be able to click on any one of the link in the page, which will bring you to the selected website reference guide: http://dojotoolkit.org/reference-gui...agination.html Hi. Please help. I have a credit card donation page and what I wanted to do is after they click the submit button and transaction is successfult I wanted to capture the donation amount they enter from the donation page and show it to the next page. I know that is possible but I just don't know how to do it. I am new in Javascript and still consider as a baby. Can someone please help? Thanks in advance.
hello, can anyone help me with a javascript-php-ajax problem? I have created a table with checkboxes and whenever an ajax function is called to refresh, the checkboxes that were highlighted and checked get reset, here is my javascript for the check function: $(document).ready(function() { $("#checkall").live('click',function(event){ $('input:checkbox:not(#checkall)').attr('checked',this.checked); //To Highlight if ($(this).attr("checked") == true) { //$(this).parents('table:eq(0)').find('tr:not(#chkrow)').css("background-color","#FF3700"); $("#policy").find('tr:not(#chkrow)').css("background-color","#FC9A01"); } else { //$(this).parents('table:eq(0)').find('tr:not(#chkrow)').css("background-color","#fff"); $("#policy").find('tr:not(#chkrow)').css("background-color","#FFF"); $("#policy").find('tr.alt:not(#chkrow)').css("background-color","#EAF2D3"); } }); $('input:checkbox:not(#checkall)').live('click',function(event) { if($("#checkall").attr('checked') == true && this.checked == false) { $("#checkall").attr('checked',false); $(this).closest('tr').css("background-color","#ffffff"); } if(this.checked == true) { $(this).closest('tr').css("background-color","#FC9A01"); CheckSelectAll(); } if(this.checked == false) { $(this).closest('tr').css("background-color","#ffffff"); $(this).closest('tr.alt').css("background-color","#EAF2D3"); } }); function CheckSelectAll() { var flag = true; $('input:checkbox:not(#checkall)').each(function() { if(this.checked == false) flag = false; }); $("#checkall").attr('checked',flag); } }); Hi i want to hide a table when user click on a link this is my code looks like PHP Code: <div id="sh"> <table width="800" border="0"> <tr> <td></td> <td></td> <td></td> </tr> </table> </div> <div align="center"><a href="JavaScript:window.print();"><img src="images/print.png" alt="Print this page"/></a></div> is it possible to hide above table at same time print this link clicked? any help would be great sorry for language errors Regards. I was wondering if anyone could help me with getting this working. I'm using html to create a table which has at least 1 row but no max number of rows - as they can be added/removed by the user - and 4 columns, 1st contains a checkbox and the last 2 contain drop down menus. I wish to be able to store the values of those menus in an array only if that row's checkbox has been checked. e.g if the first row has 1 and A as it's dropdown values and the second row has 2 and B. If only row 1 has been checked the array should only contain [1,A]. Instead mine holds all the values including the non-checked ones i.e [1,A,2,B]. My code for javascript function and html table are below: Code: function calculate(textID){ var table = document.getElementById('course'); //id of table var rowCount = table.rows.length; var array = []; //array to hold the values var c = 0; dmenus = document.getElementByTagName("select"); //get the drop down menus for(var a = 1; a < rowCount; i++){ //a = 1 as the 1st row contains column headings var row = table.rows[a]; var check = row.cells[0].childNodes[0]; if(null != check && true == check.checked){ for(var b = 0; b < dmenus.length; b++){ val = dmenus[b].options[dmenus[b].selectedIndex].value; array[c] = val; //set index of array to equal value of dropdown box c++; } }else{ b++; } } Html code for table: Code: <table id="course"> <tr> <td><input type="checkbox" name="ucheck" id="ucheck" onclick="checkAll('course')"/></td> <th style="color:white">Course Title</th> <th style="color:white">Credits</th> <th style="color:white">Grade</th> </tr> <tr> <td><input type="checkbox" name="tick" id="tick"/></td> <td><input type="text"/></td> <td> <select name="credits" id="credits"> <option...</select></td> <td> <select name="grade" id="grade"> <option...</td> It works only for the first row but if there are more than 1 row it doesn't do what it's supposed to. The coding platform I'm working on does not seem to support jquery so javascript code will be most appreciated. Thanks Ok. I'm going to start by saying I'm a complete novice. I am having a hell of time finding specific codes for the things I need. I'm pretty impressive I've gotten this far. So I am trying to make a portfolio website, for myself, which has thumbnails on the left(which I'll crop in photoshop because it is easier for me than having to do any coding) which will make the main image on the right change. At the same time, I want it to change the text below to correspond to the current image. Now I have the images swapping alright, except that the thumbnails that have the onClick function in them won't sit inside the table I have inside the table. I don't understand why that happens. I can work around this, and just get rid of that table. Another problem is that even though I defined the collumns as each being 20%, they are not all the same size. I am using percentages so that the site will function regardless of screen resolution. Anyway, here is my current code. Ignore the image names, I'm just using what random images I have at hand while I test things out. Code: <html> <head> <script type="text/javascript"> function swap(image) { document.getElementById("main").src = image.href; } </script> </head> <body> <table width="80%" align="center"> <tr><td colspan="5">I'll put a header image here.</td> </tr> <tr> <td width="20%"><center>Print</center></td> <td width="20%"><center>Motion</center></td> <td width="20%"><center>Photo</center></td> <td width="20%"><center>Misc</center></td> <td width="20%"><center>Resume</center></td> </tr> <tr> <td colspan="2"><table align="left"> <td colspan="100%">Catagory 1 </td> <tr> <a href="mario.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> <a href="../Jpg/cattits.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> <a href="bowie.jpg" onClick="swap(this); return false;"><img src="../Jpg/sluticon.jpg"></a> </tr> <td colspan="100%">Catagory 2 </td> <tr> <td><img src="../Jpg/sluticon.jpg" /></td> <td><img src="../Jpg/sluticon.jpg" /></td> </tr> </table></td> <td colspan="3"> <img id="main" src="bowie.jpg" width="400"> </td> </tr><td colspan="5"> <p>Description goes here</p></td> <tr> </tr> </table> </body> </html> OK. I'm super new to any kind of java script. What I want is a menu that, when clicked, changes the background color of a table cell to blue. When a different option is clicked, the current highlighted table should turn back to gray and the new selection should be blue. Well, I have all of that working. What I need now is just to have the first option start out highlighted and to become unhighlighted when another option is clicked. Any help would be awesome!!!! Thanks!!!!!! Code: <html> <head><title>menu</title> <script type="text/javascript"> var element = null; function select(xx) { if ( element ) { element.style.backgroundColor='gray'; } element = xx; xx.style.backgroundColor='navy'; } </script> <style type="text/css"> a {text-decoration:none; color:white} a:visited {color:white} a:active {color:white} a:hover {color:white} table#lay_menu {width:100%; margin:0px} table#lay_menu td {text-align:center; width:20%} .menu {text-align:center; background-color:gray; } .start {text-align:center; background-color:navy; } </style> </head> <body> <table id="layout"> <tr> <td width="188"> <a href="#"> <div class="menu" onClick="select(this)">Artists</div> </a></td> </tr> <tr> <td><a href="#"> <div class="menu" onClick="select(this)">CPAs</div> </a></td> </tr> <tr> <td><a href="#"> <div class="menu" onClick="select(this)">Doctors</div> </a> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> </body> </html> Code: rownumber = 2; detailsTable = document.getElementsByName("detailsTable"); detailsRow = detailsTable.getElementsByTagName("tr")[rownumber]; name = detailsRow.getElementsbyTagName("td")[0]; address = detailsRow.getElementsbyTagName("td")[1]; address2 = detailsRow.getElementsbyTagName("td")[2]; phone = detailsRow.getElementsbyTagName("td")[3]; email = detailsRow.getElementsbyTagName("td")[4]; alert(name); I have been told if I want to get the text from each cell I can use: alert(name.firstChild.nodeValue); But I don't understand how to do this for what I am wanting to do. Here is my HTML: Code: <table border="0" name="detailsTable"> <tr> <td>a</td> <td>b</td> <td>c</td> <td>d</td> <td>e</td> </tr> </table> So here's what i want to do: i have 2 checkboxes, when Checkbox A is checked, i want to automatically check the checkbox B. When A is unchecked, then uncheck B how can i do that? thanks a lot ! Here is the Code of the Table Code: <table id="commentary" class="display commentary" width="100%"> <tr class="oversummary"><td colspan="2"> </td><td> End of over 1 (13 runs) - fubar(13-1). 155 runs required from 19 overs. RR 13.00 RRR 8.16 <br/>F. Amjad 10 (4b) , C. Dowe 3 (1b) , S. Hadad 1-0-13-1 </td></tr> I want a code by which Bold text can be seen on a new window by clicking on a link and that window refreshes after 30 seconds. I have a table within a table, that is to say the table is embedded in a <tr> tag in another table and would like to extract row and cell data to make an ajax call. The table in question has several input fields and a submit button on each row. While I can find the table where the submit came from and can get the data from the <td> elements which contain data i.e.<? echo AsOfDate; ?>, I can't find the correct syntax to retrieve the data from the input fields in that same row. Can someone give me the correct syntax to retrieve the input data? Thanks, Tom var AssetTbl = document.getElementsByTagName('table'); for (i =0; i< AssetTbl.length; i++) { if (AssetTbl[i].id == "tblAssetHx") { RowID =AssetTbl[i].rows[1].cells[0].childNodes[0].data; if (RowID == ID) { // this syntax works to get the data from the non input fields // alert(AssetTbl[i].rows[1].cells[0].childNodes[0].data); // this doesn't work to get the input field data obviously! alert(document.getElementById('AssetTbl[i]').rows[1].cells[5].childNodes[0].data); } } } Table row HTML <tr> <td><? echo $AssetID; ?></td> <td><? echo $LastAsOfDate; ?></td> <td><? echo $LastQuantity; ?></td> <td><? echo $LastPrice; ?></td> <td><? echo $LastCurrentValue; ?></td> <td><input name="txtAsOfDate" id="txtAsOfDate" type="text" /></td> <td><input name="txtQuantity" id="txtQuantity" type="text" /></td> <td><input name="txtPrice" id="txtPrice" type="text" /></td> <td><input name="txtCurrentValue" id="txtCurrentValue" type="text" /></td> <td><input name="Submit" type="submit" value="Submit" onclick="GetAssetHxData(<? echo $AssetID; ?>)" /></td> </tr> hey guyz. i have a string lets say Code: mywifidata = 'a1|a2|a3|a4|b1|b2|b3|b4|c1|c2|c3|c4|'; in the string there will always be an even amount of a,b,c data i would need to fill a table 'mytable' like this a1 b1 c1 a2 b2 c2 a3 b3 c3 a4 b4 c4 i am using the pipe symbol for the delimiter the actual data is wifi data like mywifiname1 on 70 mywifiname2 on 51 mywifiname3 off 57 mywifiname4 on 22 and to customise it i would like to replace the on and off with an image so if its on then <img src="padlock.png"> if off <img src="nolock.png"> and for the numeric values i would like a progressbar or something that would show the signal strength out of 70 also each wifiname td would need an id that increments like wifi1 wifi2 wifi3 wifi4 and each of those td will need an onclick="highlight(this.id)" i know i am being cheaky for asking all of this but i am willing to pay a few quid if someone could help me out Hi there, I am trying to extract all of the values from the 5th column (Assignee) in this HTML table http://bugzilla.maptools.org/buglist...icksearch=test and don't know how to proceed. Is there a clever way of getting the entire col class: <col class="bz_op_sys_column"> before putting into an array. thanks, kev |