JavaScript - Edit Multiple Checkbox(urgent)
i have a multiple checkbox of options1,options2,options3,options4.i want to do when i add options1,options2,options3 it will shows on the database.and when i will go to my edit page it will shows that the options1,options2And options3 are already checked.how can i do this?please anybody help me .my code is below
body portion <body> <form name="name" method="post" id="f1" action="insertpage.php"> <fieldset><legend align="center">Page Information</legend> Page Title:<input type="text" name="pagetitle" /> <br /> page Description:<textarea name="pagedescription"></textarea> <br /> Keywords:<input type="text" name="keywords"><br /> Content:<textarea name="content"></textarea><br /> <INPUT NAME="options" TYPE="CHECKBOX" value="1"> Option 1<BR> <INPUT NAME="options" TYPE="CHECKBOX" VALUE="2"> Option 2<BR> <INPUT NAME="options" TYPE="CHECKBOX" VALUE="3"> Option 3<BR> <INPUT NAME="options" TYPE="CHECKBOX" VALUE="4"> Option 4<BR> <input type="submit" value="Add" id="f1" name="submit"> </fieldset> </form> </body> insert page <?php include 'config.php'; //require_once 'includes/sessions.php'; $pt=$_REQUEST['pagetitle']; $md=$_REQUEST['pagedescription']; $mk=$_REQUEST['keywords']; $mc=$_REQUEST['content']; $chk=$_REQUEST['options']; $sql="insert into `page`(`page_title`,`meta_des`,`meta_keywords`,`meta_content`,`checkbox1`)values('$pt','$md','$mk',' $mc','$chk')"; $r=mysql_query($sql) or die ("Couldn't select" . mysql_error()); ?> edit page <?php $id=$_REQUEST['id']; $pt=$_REQUEST['pagetitle']; $md=$_REQUEST['pagedescription']; $mk=$_REQUEST['keywords']; $mc=$_REQUEST['content']; $chk=$_REQUEST['options']; $sql="update `page` set `page_title`='$pt',`meta_des`='$md',`meta_keywords`='$mk',`meta_content`='$mc',`checkbox1`='$chk' where `page_id`='$id'"; $r=mysql_query($sql)or die ("Couldn't select" . mysql_error()); header("locationage1.php?id=<?php echo $id;?>"); ?> <?php session_start(); //require_once 'includes/sessions.php'; include 'config.php'; $id=$_REQUEST['id']; $query="select * from `page` where page_id=".$id; $result=mysql_query($query) or die ("Couldn't select" . mysql_error()); $row=mysql_fetch_array($result); ?> editview page <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form name="name" method="post" id="f1" action="page2.php?id=<?php echo $id;?>"> <fieldset><legend align="center">Page Information</legend> Page Title:<input type="text" name="pagetitle" value="<?php echo $row['page_title'];?>" /> <br /> page Description:<textarea name="pagedescription" ><?php echo $row['meta_des'];?></textarea> <br /> Keywords:<input type="text" name="keywords" value="<?php echo $row['meta_keywords'];?>"/><br /> Content:<textarea name="content"><?php echo $row['meta_content'];?></textarea><br /> <INPUT NAME="options" TYPE="CHECKBOX" VALUE="<?php echo $row['checkbox'];?>"> Option 1<BR> <INPUT NAME="options" TYPE="CHECKBOX" VALUE="<?php echo $row['checkbox'];?>"> Option 2<BR> <INPUT NAME="options" TYPE="CHECKBOX" VALUE="<?php echo $row['checkbox'];?>"> Option 3<BR> <INPUT NAME="options" TYPE="CHECKBOX" VALUE="<?php echo $row['checkbox'];?>"> Option 4<BR> <input type="submit" value="Update" id="f1" name="submit"> </fieldset> </form> </body> Similar TutorialsHello. I have a for loop, that automatically creates textfields and checkboxes. These of course have the same name and I am using request.getParameterValues to retrieve them. However, I am struggling on this rather simple issue. I am no javascript guru, so maybe you guys could help me out. I have tried googling for this answer, but havent found anything that can help my problem exactly. I have three text fields on each row and one checkbox. I would like for each checkbox I click, that the textfields to be enabled. A sample code he Code: <td><input type="text" size="10" name="pris" disabled="disabled"></td> <td><input type="text" size="10" name="toppfart" disabled="disabled"></td> <td><input type="text" size="10" name="motorinstallasjon" disabled="disabled"></td> <td><input type="checkbox" name="motorCheckbox" value="<%=motor.getId()%>" onclick="(pris.disabled=!this.checked)& (toppfart.disabled=!this.checked)& (motorinstallasjon.disabled=!this.checked)"> </td> However this doesnt quite work :-) I have tried with document.Form.pris but that didnt help either. I posted a thread a few days ago concerning a bit of javascript code to make checking one checkbox clear another one. I got some great, prompt help. However, I just got back to working on that web page, and realized that the functions only work on the first form on my web page. I have many forms and they are actively named using php. Here's are the functions (these works for just the first form on the page): Code: <script type="text/javascript"> function undo_Changes() { if (document.getElementById("Complete").checked==true) { document.getElementById("Needs_Change").checked=false; } } function undo_Complete() { if (document.getElementById("Needs_Change").checked==true) { document.getElementById("Complete").checked=false; } } </script> I call them from the checkboxes involved: Code: <input name="Complete" id="Complete" value="Yes" <?php echo($Complete=="Yes") ? "checked" : ""; ?> size="4" type="checkbox" onChange="this.style.color='#FF0000'" onClick="undo_Changes()"> <input name="Needs_Change" id="Needs_Change" value="Yes" <?php echo($Needs_Change=="Yes") ? "checked" : ""; ?> size="4" type="checkbox" onClick="undo_Complete()"> Here's how my forms are named: Code: <?php $DocName = "Schedule".$count; ?> <form name="<?php echo $DocName; ?>" action="ScheduleCode.php" method="post" id="<?php echo $DocName; ?>"> I've tried the following and it doesn't work at all: Code: <script type="text/javascript"> function undo_Changes(myForm) { if (myForm.getElementById("Complete").checked==true) { myForm.getElementById("Needs_Change").checked=false; } } function undo_Complete(myForm) { if (myForm.getElementById("Needs_Change").checked==true) { myForm.getElementById("Complete").checked=false; } } </script> <input name="Complete" id="Complete" value="Yes" <?php echo($Complete=="Yes") ? "checked" : ""; ?> size="4" type="checkbox" onChange="this.style.color='#FF0000'" onClick="undo_Changes(this.form)"> <input name="Needs_Change" id="Needs_Change" value="Yes" <?php echo($Needs_Change=="Yes") ? "checked" : ""; ?> size="4" type="checkbox" onClick="undo_Complete(this.form)"> Thanks for any help. Lisa print "<Font face=\"calibri, Arial\"><table id=\"rnatable\" border=2px width=100%>"; print "<th></th>"; print "<th>a</th>"; print "<th>b</th>"; print "<th>c</th>"; print "<th>d</th>"; print "<th>e</th>"; print "<th>f</th>"; print "<th>g</th>"; while($array = mysql_fetch_array($sql_query)) { $id=$array['a']; print "<tr id=\"newtr\">"; print "<td><input id=\"check\" type=\"checkbox\" name=\"keyword[]\" value=\"$id\" ></td>"; print "<td>".$array['a']."</td>"; print "<td>".$array['b']."</td>"; print "<td>".$array['c']."</td>"; print "<td>".$array['d']."</td>"; print "<td>".$array['e']."</td>"; print "<td>".$array['f']."</td>"; print "<td> <a href=\"http://localhost/rnasearch/retrieve.php?a=$id\">bla</a> </td></tr></font>"; } print "</table>"; } this is part of a php searchengine script that i wrote to retrieve data from a database and as you can see the last column that is g contains a link which when clicked takes the user to the second php script which retrieves additional information of that entry, but this is done for only single entries so as you can see i introduced checkboxes so that the user can check any number of checkboxes and retrieve information as per their wish now to do this i created a <input type=text where i want the value of these checkboxes i.e. $id to be posted in a delimited format so that the user can then click the corresponding button and retrieve the information this is the code <div id="floatMenu"> <ul class="menu1"> <center><li><form name="senddata" method="POST" action="http://localhost/retrieve.php" style="display:inline;"><input id="fasta" type="text" class="multitext"><input name="Fasta" type="Submit" value="Retrieve Fasta"></form> this is a css floating menu....so far so good....everything went fine.... after this i had to write a javascript to do this and i've been stuck there searching forums for the last 4 days! this is the javascript i found from somewhere which came close to doing wht i wanted it to do window.onload = function () { var cb = document.getElementById('check'); var fasta = document.getElementById('fasta'); cb.onclick = function () {fasta.value = cb.value + ","; };}; this script only sends the value of the first checkbox in the table, the others are not found by it, mind you its not the first checkbox selected its the first checkbox that is present in the table how can i resolve this problem so that even if i have n number of checkboxes in my table, if the user chooses to do so they can retrieve n number of information....please help i've almost lost hope in this! 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 ! Hi, If I have two check-boxes and one is already checked and then the is checked, how would I get it to uncheck the first one using JavaScript. Thanks, Cs1h here's what I have so far Code: <html> <head> <script> MONTHS_OF_THE_YEAR = 'janfebmaraprmayjunjulaugsepoctnovdec'; MILLISECONDS_DAY = 1000*60*60*24; MILLISECONDS_YEAR = 1000*60*60*24*365.2424; LIFE_EXPECTANCY = 1000*60*60*24*365.2424*67.2; var daysArray = new Array ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); var yearBirth = ''; yearBirth = prompt('Please enter your year of birth'); var monthBirth = ''; monthBirth = prompt('Please enter your month of birth'); monthBirth = monthBirth.slice(0,3); monthBirth = monthBirth.toLowerCase(); monthBirth = MONTHS_OF_THE_YEAR.indexOf(''+monthBirth)/3; var dateBirth = ''; dateBirth = prompt('Please enter your date of birth'); var usersInputDate = new Date (yearBirth, monthBirth, dateBirth); var dd = new Date((monthBirth+1).toString() + "/" + dateBirth + "/" + yearBirth); dd=dd.getDay(); var now = new Date(); usersInputTime = (usersInputDate.getTime()); usersInputTime = parseInt(now.getTime()-usersInputTime); var ageYears = (usersInputTime/MILLISECONDS_YEAR); var ageDays = (usersInputTime/MILLISECONDS_DAY); var avgLife = (usersInputTime/LIFE_EXPECTANCY*100); document.writeln('<h1>It\'s about time...</h1>'); document.writeln('<ul>'); document.writeln('<li> </li>' </script> </head> <body> </body> </html> I need to do the following and have no idea Quote: What will be output (to the document using write())? A heading 1 title with the text It's about time... An unordered list containing appropriate wording as strings concatenated with: The weekday name for the user's birth date Use the day of the week number as an index into the weekday names array The user's age in years Present this as a fixed format number with 2 decimal places The user's age in days Present this as a fixed format number with 0 decimal places The percentage of an average life expectancy Present this as a fixed format number with 0 decimal places please help i need to get this done tonight I am a beginner so please help ASAP. When I validate my code in validate.w3.org: document.write("<img src='" + myNum +".jpg'/>"); I got an error that said: --- required attribute "alt" not specified I have a page in html, containing some text like " ABCDEFGHIJKL" etc. This text has also a website link (hyperlink) with it. This website link changes on each refresh of page. Such link changes due to javascript runing behind on it. I just want this link each time stored in a PHP variable. Such text always appears on a certain position on the page (X,Y). Can you please help me on it.? I can provide additional details on request. Your early answer is required. Regards Ahmed Taufiq Hi, i am new to javascript and i am giving a task to create a javascript page, i need a javascript that will calculate and generate a simple Quotation with total price of item selected and its quantity in a new page and in tabular form, i need this for 2 check-boxs that has the value, 2 dropdownlist and the price.
can any one please help me out with the code. I am passing an URL for ex: www.example.com?req=23¶m=25 What i need to do is I need to remove the parameters after "?" which I did using the spilt method, Can anyone help me out now how do I send the complete URL with the parameters as hidden. what I mean is..my URL should look like www.example.com. but the second part (parameter shud be hidden). im new beginner for jsp coding and java script programming..here,i have a few question about date calculation. 1.duration date between date signed and expired date = display in year 2. from expired date available years, month and day minus with Date Today 3. how to use IF ELSE statement to display status active or inactive (example : active status if more then 8 month or inactive status if less then 8 month) this is my coding...it's right? for years <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ function DaysMonths(but,nme,op){ var frm=but.form; var dates=frm[nme]; for (var i=0; i<dates.length; i++){ var date=dates[i].value.split('-'); dates[i].date=new Date(date[0]*1,date[1]-1,date[2],0,0,0,0); } var days=(dates[1].date-dates[0].date)/1000/60/60/12; years=(dates[1].date.getFullYear()-dates[0].date.getFullYear()); frm[op].value=years+' years'; } /*]]>*/ </script> i have output : 5 years for month and day <script language="JavaScript" type="text/javascript"> /*<![CDATA[*/ function DaysMonth(but,nme,op){ var d = new Date(); var frm=but.form; var dates=frm[nme]; for (var i=0; i<dates.length; i++){ var date=dates[i].value.split('-'); dates[i].date=new Date(date[0]*1,date[1]-1,date[2],0,0,0,0); } var days=(dates[1].date-dates[0].date)/1000/60/60/24s; var months=dates[1].date.getMonth()-dates[0].date.getMonth(); months=(dates[1].date.getFullYear()-dates[0].date.getFullYear()-d.getDate())*12+(months<0?months:-months); frm[op].value= months + ' month ' +days+ ' day '; } /*]]>*/ </script> my output i have like this : 48 month 1826 day i set date format in my sql like this date signed = 2008-11-18 date expired = 2013-11-18 how can i have output like this for for duration (date expired - date signed) minus date for today = 3 year, 42 month 1826 day sorry for my thread post this morning...not mean like that... Hai everyone, I am a newbie to javascript.I have a scenario where I have two sets of textboxes,one that holds the percentage and other holds the percenteage value. Below them,I have a total value of which the percentage values will be stored. Can anyone help me in writing the javascript code in finding the percentage value of the total number given below and storing it in a text box. Any help,I need it urgent Hi I'm trying to create a javascript function that will ask a user for a character and check that character against a string containing other characters. If the character is present in the string the function should then ask the user to input another character. it should keep doing this until a charater is entered that doesnt appear in the check string. I am pretty new to javascript and have been working for about 2 days trying to get this to work. I have an assignment due next week 21.09.09 and need to get it sorted before then. Any help or pointers would be great. One stipulation that the assignment is asking for is that you have to use the indexOf method to interigate the string. I have attached the code below. Any help or pointers would be brilliant. var incorrectString = 'abcdef'; var correctString = 'ghi'; function getInput(aString) { } getInput(incorrectString + correctString); I'm a newbie to php and javascript. I want some checkbox to hide some rows of my table so i did a search and i found a few javascript codes but yet I couldn't make it work the way I wanted it. When I uncheck a checkbox ONLY the first table rows get hidden, the other tables don't? can't I ID some rows? Please I need help :( My javascript code is: Quote: <script type="text/javascript"><!-- function showHideTR(idx,vis) { var tbl,row; if(document.getElementById && document.getElementsByTagName) { tbl = document.getElementById('tbl'); if(!tbl || (idx >= tbl.getElementsByTagName('tr').length)) return; row = tbl.getElementsByTagName('tr')[idx]; } else if(document.all && document.all.tags) { // IE4 support tbl = document.all.tbl; if(!tbl || (idx >= tbl.all.tags('tr').length)) return; row = tbl.all.tags('tr')[idx]; } if(row) { if(!vis) { row.style.display = 'none'; } else { // conditional compilation to hide the try-catch blocks from IE4 /*@cc_on @if(!@_jscript || (@_jscript_version >= 5)) @*/ try { row.style.display = 'table-row'; } catch(e) { row.style.display = 'block'; } /*@elif(@_jscript_version < 5) row.style.display = 'block'; // for IE4 @end @*/ } } } function getStyle(el,styleProp) { var x = (typeof(el)=='string')?document.getElementById(el):el; if (x.currentStyle) var y = x.currentStyle[styleProp]; else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); return y; } window.onload = function() { if(!document.getElementsByTagName) return; var tds = document.getElementsByTagName('td'); for(var i=0;i<tds.length;i++) { tds[i].onclick = function() { alert(this.parentNode.tagName+' = display : '+getStyle(this.parentNode,'display')+ '\n'+this.tagName+' = display : '+getStyle(this,'display')); } } } // --> </script> <!-- <script type="text/javascript"> function showHideTR(idx,vis) { var tbl,val; val = (!vis)?'none':((document.defaultCharset && !window.home)?'block': 'table-row'); if(document.getElementById && document.getElementsByTagName) { tbl = document.getElementById('tbl'); if(idx >= tbl.getElementsByTagName('tr').length) return; tbl.getElementsByTagName('tr')[idx].style.display = val; } else if(document.all && document.all.tags) { // IE4 support tbl = document.all.tbl; if(idx >= tbl.all.tags('tr').length) return; tbl.all.tags('tr')[idx].style.display = val; } } </script> --> My option tags: Quote: <form action="#" onsubmit="return false;"> <ul> <li2><label for="cb0"><input type="checkbox" id="cb0" checked="checked" onclick="showHideTR(0,this.checked);"> Blah Blah</label></li> <li2><label for="cb1"><input type="checkbox" id="cb1" checked="checked" onclick="showHideTR(1,this.checked);"> Blah Blah2</label></li> <li2><label for="cb2"><input type="checkbox" id="cb2" checked="checked" onclick="showHideTR(2,this.checked);"> Blah Blah3</label></li> <li2><label for="cb3"><input type="checkbox" id="cb1" checked="checked" onclick="showHideTR(3,this.checked);"> Blah Blah4</label></li> </ul> </form> My php page: Quote: <?php $host = "localhost"; // your host name $username = "blah blah"; // your user name to access MySql $password = "blah blah"; // your password to access MySql $database = "blah blah"; // The name of the database $no = $_POST["sureno"]; //$link = mysql_connect($host,$username,$password); if (!$link = @mysql_connect($host,$username,$password,true)) {die('Could not connect:'. mysql_error()); } @mysql_query("SET NAMES 'latin5'"); @mysql_select_db($database) or die( "Unable to select database"); $sql="SELECT * FROM blah blah WHERE sure = '$no' ORDER BY 'id'"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } while($row=mysql_fetch_assoc($result)){ $bgcolor="#f1f1f1"; echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0 id='tbl' summary='demonstration'> <tr>"; echo "<td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='C0C0C0' ><font face='arial,verdana,helvetica' color='#FF0000' size='4'>" . $row['AB'] ."</font></td></tr>"; echo "<tr><td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='dfdfdf'> <font face='arial,verdana,helvetica' color='#0080C0' size='2'>". $row['TR'] ."</font></td></tr>"; echo "<tr><td bgcolor='dfdfdf' ><font face='arial,verdana,helvetica' color='#000000' size='3'>blah blah</font></td>"; echo "<td bgcolor='dfdfdf' id='cb0'> <font face='arial,verdana,helvetica' color='#000000' size='3'>". $row['ML'] ."</font></td></tr>"; } mysql_free_result($result); ?> Hi Guys, I am implementing this Javascript in my summer internship. What I want to do is, 1) Show a Pop up alert with a Countdown timer( 10, 9, 8, 7 ....) after 5 minutes. 2) If user doesn't click "Ok" within the time, the page will automatically Redirect to another page. Eg- Login Page. 3) If the User clicks the "Ok" button the Page will not get re-direct. 4) Also, once the Timer countdown completes and the page redirection is done, the User when he will see the Login page will see an alert box saying. 'Your session has expired, plz login again' he clicks 'Ok' and Login again. I am very new to this Java script, but need to finish this project. Plz help me out. is it possible to open all file of a folder with multiple folders inside in turn opening all files. basically i have some sites i need to fully edit but i rather work with every file from the website open i need to open every file in a folder of files in other folder help i cant go one by one it would take forever.
I want to insert image instead of those empty boxes.......can someone help me please...... <script type="text/javascript"> document.write("<html><head><title>My PhotoCollage</title></head><body>"); function makeDiv() { var r = Math.floor(Math.random()*256); var g = Math.floor(Math.random()*256); var b = Math.floor(Math.random()*256); var wh = 25 + Math.floor(Math.random()*444); var lr = (Math.random()<.5) ? "top":"right"; var bw = 1 + Math.floor(Math.random()*12); var bs = (Math.random()<.5) ? " solid":"dotted"; var dc = (Math.random()<.5) ? "Dog" : "Cat"; var Img = Math.floor(Math.random()*256); document.write("<div style=\"float: "+lr+";"+ "width: "+wh+"px;"+ "height: "+wh+"px;"+ "border: rgb(" + g + "," + b + "," + r + ") "+bw+"px "+bs+";"+ "background-color: rgb(" + r + "," + g + "," + b + ");"+ "image: "\">"+dc+ "</div>"); } var i; var count = Math.floor(Math.random()*100) + 5; for (i=0; i<count; i++) makeDiv(); document.write("</body></html>"); </script> Hi I'm trying to download the security image from this site (at the bottom): http://pacesalsa.promotionexpert.com...2/register.jsp However, every time one refreshes the image, the image changes (obviously). So, I'm trying to figure out how to download the current image on the page to a jpg or png (or any image file type). Could someone please tell me how to do this? Thanks. I have been trying for hours to do the following: - Change the background of a div by clicking a link from another div tag. - It also needs to change back when clicked again. I know there are alot of experienced coders out there and I'm eager to learn... help would be appreciated! I am not a JavaScript resource , on an urgent basis I need to create a GUI screen with the help javascript for running reports i.e. the parameters would be passed to reports that are to be run. My requirement is to create : User friendly drop down box A date field with calender in it so taht value can be selected from the calender and passed on to the database. A option on the GUI that would create a csv file on the server. |