colap
-
Posts
302 -
Joined
-
Last visited
Posts posted by colap
-
-
Sure you can!
Put this beween <head></head>
<style type="text/css">
#Div1 {
left:431px;
top:30px;
}
</style>
<?php echo "<div id='Div1'>Hello world!!</div>";?>
Is that what you mean??
No, i want to put/place a web page in that div,not only "Hell world".
And it will happen after clicking the button.
Can someone give some clue for that?
-
If i click a button then a new page will come in a div.
Is it possible with php?
I have tried this but it doesn't work.
<?php if(isset($_POST['nmdiv'])) { echo "<div class=\"cldiv1\" id=\"iddiv1\"><?php include(\"copyright.php\")?></div>"; } ?> <html> <head> <title>phptest</title> <script type="text/javascript" language="javascript"> function makediv(){ var tmp=document.getElementById("iddiv1"); tmp.style.border="solid"; tmp.style.position="absolute"; tmp.style.left="300px"; tmp.style.top="100px"; tmp.style.width="400px"; tmp.style.height="200px"; } </script> </head> <body> <form method="post"> <input type="button" name="nmdiv" value="click" onclick="makediv()"/> </form> </body> </html>
-
-
include("database_connector.php"); $admin_id = $_POST['admin_id']; $admin_password = $_POST['admin_password']; $cmd1=mysql_query("select * from admin where admin_id='$admin_id' AND password='$admin_password'"); //$row1=mysql_fetch_array($cmd1, MYSQL_NUM); //$row1=mysql_fetch_row($cmd1); $count1=mysql_num_rows($cmd1); if($count1==1) {
-
Could be done with a database and AJAX. Or without AJAX, if you can live with it reloading the page on submit.
Can you please give link for that or sample example?
-
I have a main div.
javascript code has been added to create new div.
If i type in a textarea and click "ok" button a new div will be created containing that message from textarea.
Now if i reload the page the newly created divs are gone.
I want to save this new divs with that page.
If i reload that page or open that page with another browser or from another browser window the web page will contain those divs.
Is it possible to do this?
-
Thank you.Solved.
-
Hi
In the remove function you are trying to remove a div called DIV1 (for example), having passed the number 1. However the divs you are adding are called my1 (for example).
Change:-
var olddiv = document.getElementById('DIV'+divNum);
to
var olddiv = document.getElementById('my'+divNum);
All the best
Keith
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.
-
You're not actually calling removeElement() anywhere.
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.
-
I only gave it a quick glance, but try changing this:
var olddiv = document.getElementById(divNum);
to this:
var olddiv = document.getElementById("div" + divNum);
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>
-
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>
-
-
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.
-
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>
-
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";
-
If i click the button it's not redirected to new page.
Where would i change in my code?
Where is the error?
-
<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>
-
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>
-
Well then you'll need 3 different forms, or to use JavaScript. JS however, as mentioned before, is un-reliable.
Going with a similar idea to mine though; you could link to the other page, decide on the action you need to take, and then redirect as appropriate. Look into header for that.
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>
-
You need to link the form to your PHP file, and then check to see which submit button was pressed using a pretty simple series of IF statements... for example:
HTML:
<form action="yourpage.php" action="post"> <input name="ins" type="submit" value="INSERT"> <input name="upt" type="submit" value="UPDATE"> <input name="del" type="submit" value="DELETE"> </form>
"yourpage.php":
if (isset($_POST['ins'])) { echo 'INSERT...'; } elseif (isset($_POST['upt'])) { echo 'UPDATE...'; } elseif (isset($_POST['del'])) { echo 'DELETE...'; }
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".
-
<form> <input name="ins" type="submit" value="INSERT"> <input name="upt" type="submit" value="UPDATE"> <input name="del" type="submit" value="DELETE"> </form>
-
I want to navigate/redirect php page with html buttons.
Can anyone post sample code?
Html button navigation with click event.
(Javascript if necessary)
-
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?
-
Look in your programming editor's file save choices.
That was written in Adobe Dreamweaver , now i'm editing with vim editor in linux.
What should i do now?
[SOLVED] $_GET["i"] and $_GET["a"]
in PHP Coding Help
Posted
Can you please explain your problem in details?