Jump to content

colap

Members
  • Posts

    302
  • Joined

  • Last visited

Everything posted by colap

  1. I have also tried with 'my'.But didn't work. Probably there is a mistake with removeElement() function calling but i can't find it.
  2. Here we go: newdiv.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>'; Probably something is wrong here.But i can't find it. How would i add a button in that new div? I want to test with a button instead of <a href> link.
  3. Changed it.But it doesn't work. <html> <head> <title> "Javascript Testing"></title> <script type="text/javascript" language="javascript"> function addElement() { var ni = document.getElementById('myDiv'); var numi = document.getElementById('theValue'); var num = (document.getElementById('theValue').value -1)+ 2; numi.value = num; var newdiv = document.createElement('div'); var divIdName = 'my'+num; var writediv=document.getElementById('idrgt'); writediv.innerHTML="divIdName: "+divIdName+"<br/>"; newdiv.setAttribute('id',divIdName); newdiv.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>'; ni.appendChild(newdiv); } function removeElement(divNum) { var d = document.getElementById('myDiv'); var olddiv = document.getElementById('DIV'+divNum); d.removeChild(olddiv); } </script> <style type="text/css"> div.div1{ width:400px; height:70px; background-color:green; } div.rgt{ position:absolute; left:500px; top:300px; width:400px; height:70px; background-color:blue; } div.del{ position:absolute; left:500px; top:100px; width:400px; height:70px; background-color:red; } </style> </head> <body> <div class="div1" id="myDiv"> <textarea rows="2" cols="20"> Comment; </textarea> <input type="hidden" value="0" id="theValue" /> <input type="submit" value="Submit" onclick="addElement()"/> </div> <div class="rgt" id="idrgt"> </div> <div class="del"> </div> </body> </html>
  4. Adding divs work,but removing divs don't work. http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/ <html> <head> <title> "Javascript Testing"></title> <script type="text/javascript" language="javascript"> function addElement() { var ni = document.getElementById('myDiv'); var numi = document.getElementById('theValue'); var num = (document.getElementById('theValue').value -1)+ 2; numi.value = num; var newdiv = document.createElement('div'); var divIdName = 'my'+num; var writediv=document.getElementById('idrgt'); writediv.innerHTML="divIdName: "+divIdName+"<br/>"; newdiv.setAttribute('id',divIdName); newdiv.innerHTML = 'Element Number '+num+' has been added! <a href=\'#\' onclick=\'removeElement('+divIdName+')\'>Remove the div "'+divIdName+'"</a>'; ni.appendChild(newdiv); } function removeElement(divNum) { var d = document.getElementById('myDiv'); var olddiv = document.getElementById(divNum); d.removeChild(olddiv); } </script> <style type="text/css"> div.div1{ width:400px; height:70px; background-color:green; } div.rgt{ position:absolute; left:500px; top:300px; width:400px; height:70px; background-color:blue; } div.del{ position:absolute; left:500px; top:100px; width:400px; height:70px; background-color:red; } </style> </head> <body> <div class="div1" id="myDiv"> <textarea rows="2" cols="20"> Comment; </textarea> <input type="hidden" value="0" id="theValue" /> <input type="submit" value="Submit" onclick="addElement()"/> </div> <div class="rgt" id="idrgt"> </div> <div class="del"> </div> </body> </html>
  5. else if($submitted_by_admin=$_POST['submitted_by_admin']=='yes_admin') { // echo "admin:".$submitted_by_admin; include("database_connector.php"); $admin_id = $_POST['admin_id']; $admin_password = $_POST['admin_password']; $cmd1=mysql_query("select *from admin_info where user_name='$admin_id' AND password='$admin_password'"); $row1=mysql_fetch_array($cmd1); ****************/error $count1=mysql_num_rows($cmd1); ****************/error Error is shown on last two lines.
  6. Should i edit conditional statements in the <?php ?> block to make it more efficient code? How can i make this code more efficient? <?php session_start();?> <?php if($_POST['ins']){ header('Location:stp.php'); } if($_POST['upt']){ header('Location:byte.html'); } ?> <html> <head> <title>Welcome</title> </head> <body> <form method="post"> <input name="ins" type="submit" value="INSERT"/> </form> <form method="post"> <input name="upt" type="submit" value="UPDATE"/> </form> <form method="post"> <input name="del" type="submit" value="DELETE"/> </form> </body> </html>
  7. Why do they all work? document.location="byte.html"; document.location.href="byte.html"; window.location="byte.html"; window.location.href="byte.html"; location.href="byte.html";
  8. If i click the button it's not redirected to new page. Where would i change in my code? Where is the error?
  9. <script type="text/javascript" language="javascript"> function thatpage(){ document.URL="byte.html"; } </script> <form> <input name="ins" type="submit" value="INSERT" onclick="thatpage"/> <input name="upt" type="submit" value="UPDATE"/> <input name="del" type="submit" value="DELETE"/> </form>
  10. It works.But how would i use header() here instead of action=""? <form action="byte.html"> <input name="ins" type="submit" value="INSERT"> </form> <form action="stp.php"> <input name="upt" type="submit" value="UPDATE"> </form>
  11. Why isn't javascript reliable? I have also tried this.But it's not working. <form > <input name="ins" type="submit" value="INSERT" onclick="location.href='byte.html'"> <input name="upt" type="submit" value="UPDATE"> <input name="del" type="submit" value="DELETE"> </form>
  12. No. If i click insert button,it will redirect to insert.php file,similarly update button-->update.php delete button -->delete.php I don't want to display the yourpage.php file for the click event of these three buttons. I'm trying "different page display for different button's click event".
  13. <form> <input name="ins" type="submit" value="INSERT"> <input name="upt" type="submit" value="UPDATE"> <input name="del" type="submit" value="DELETE"> </form>
  14. I want to navigate/redirect php page with html buttons. Can anyone post sample code? Html button navigation with click event. (Javascript if necessary)
  15. I have four buttons on a php page. If i click a button it will redirect to different php pages. How would i do that with php?
  16. That was written in Adobe Dreamweaver , now i'm editing with vim editor in linux. What should i do now?
  17. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at index.php:1) in index.php on line 2 <?php session_start(); $errorMessage = ''; if($submitted_by_user=$_POST['submitted_by_user']=='yes') { echo "User: ".$submitted_by_user; include("database_connector.php"); $user_id = $_POST['user_id']; //$password = $_POST['password']; $cmd=mysql_query("select * from student_personal where reg_no='$user_id'"); if(!$cmd)
  18. I get the databases from C:\wamp\bin\mysql\mysql5.1.36\data in windows. Where are those databases in linux? I can use databases in linux from terminal using mysql -u root -p password:***** I want to find them in linux.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.