PHP - Innerhtml == Php ! Javascript
It has been ten years since I last wrote any code. I am trying to use PHP to write into a HTML element. I know JavaScript has the innerHTML function but I cannot seem to find any equivalent PHP function. My questions are
1) Is there an equivalent PHP function to innerHTML? If not 2) Is there an intelligent method of using PHP fire JavaScript innerHTML Why? I want to get data from MySQL DB using PHP and print one record at a time to the webpage. I will be using a <div> tag as the data will be longer then one line so I do not want to use a span tag. I would like to force line breaks therefore I am using CSS with 'display:block;' I have not found a way to print the data from MySQL Similar TutorialsHow to set innerHTML of DomNode? I am parsing html.I want to change a html of DomNode/DomElement? How to achieve the same? Thanks in advance CSJakharia Hi, It appears I ran into the dreaded IE <select> issue with innerhtml. I have looked at multiple solutions but alas I reach out for help! The code works beautifully in Safari and Firefox but fails in IE by simply loading blanks when AJAX is called. I read up on microsoft.com a DIV may work outside the <select>. But I must be messing something up. Thanks for your puzzle solving help! Code: AJAX: xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4) { var temp=(xmlHttp.responseText); document.getElementById("option").innerHTML=temp; } } var queryString = "?page=" + page; xmlHttp.open("GET","AJAX_page.php" + queryString,true); xmlHttp.send(null); PHP: <?php echo "<form action='next.php' method='POST'>"; echo "<select name='id' id='option'><option value=0>Option_0/option>"; { echo "<option value ='$id'>$choice</option>"; } echo "</select>"; echo "<input type='submit' value='Submit'></form>"; ?> Hello, i am trying to pull the innerHTML out of this: Code: [Select] <a href="(.*?)">(.*?)</a> here is what I have: Code: [Select] <?php $html = file_get_contents("http://www.businessinvestingsource.com/blcheck2.html"); preg_match_all('/<a href="(.*?)">(.*?)<\/a>/', $html, $links, PREG_SET_ORDER); foreach ($links as $link) { $linkto = $link[1]; $anchor = $link[0]; echo "<b>Link:</b> ".$linkto."<br /><b>Anchor:</b> ".$anchor."<br /><br /> "; } ?> Now this code works but the innerHTML is coming out as a link I want it to come out as plaintext you can view he http://businessinvestingsource.com/anchorcheck2.php Can anyone help? Thank you. what is the best way yo do this? Code: [Select] <b><font color=green>Get me out please </font> . </b> thanks in advance I wonder whether someone may be able to help me please. I'm currently running the code below (originating from nearby.org.uk) to convert OS Grid References to Latitude and Longtiude co-ordinates. Code: [Select] function converttolatlng() { var gr = document.getElementById('osgridref').value; var osgb = new GT_OSGB(); if (osgb.parseGridRef(gr)) { var wgs84 = osgb.getWGS84(); document.getElementById('osgb36lat').value = wgs84.latitude; document.getElementById('osgb36lon').value = wgs84.longitude; } else { document.getElementById('osgb36lat').value = "n/a"; document.getElementById('osgb36lon').value = "n/a"; } } This code is run through a 'click' event from a button on a HTML form and then the record is saved to a mySQL database. However, once a month, I have a list of approx 20,000 OS Grid References which need converting and saving to the same mySQL database. To do this manually on a button click wouldn't be very practical, so I've been working on doing this automatically. I may very well be doing this the wrong way, but I've been using the PHP script below to extract the two pieces of information I need from the xml file, the first is the 'Name, and the second is the 'NGR', and it is this field that needs converting. Code: [Select] <? $objDOM = new DOMDocument(); $objDOM->load("scheduledmonuments.xml"); $Details = $objDOM->getElementsByTagName("Details"); foreach( $Details as $value ) { $Name = $value->getElementsByTagName("Name"); $name = $Name->item(0)->nodeValue; $NGR = $value->getElementsByTagName("NGR"); $ngr = $NGR->item(0)->nodeValue; echo "$name :: $ngr <br>"; } ?> This is where I've become a little stuck because I'm not sure how to get the data converted and to a point where it can be saved to the relevant fields in my database. I just wondered whether someone would perhaps take a look at this please and let me know what I need to do. Many thanks Hello, I'm currently working on a gaming website, however there is an issue. I have a custom YouTube player, however I need to get the link dependant on a value from the database. The ID is in the URL, which is then collecting the youtube video URL from the database. However, I'm trying to then echo that back out into the Javascript video. On my normal page, that plays the Video is: Header: Styles.css & youTubeEmbed-jquery-1.0.css need to be added. Code: [Select] <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Having Fun With YouTube's API - Making a Custom Video Player | Tutorialzine Demo</title> <link rel="stylesheet" type="text/css" href="styles.css" /> <link rel="stylesheet" type="text/css" href="video_player/youTubeEmbed/youTubeEmbed-jquery-1.0.css" /> </head> Footer: All of that needs to be added. Code: [Select] <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="jquery.swfobject.1-1-1.min.js"></script> <script src="youTubeEmbed/youTubeEmbed-jquery-1.0.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#player').youTubeEmbed("VID LINK FROM DB SHOULD BE HERE"); $('form').submit(function(){ $('#player').youTubeEmbed({ video : 'VID LINK FROM DB SHOULD BE HERE', width : 640, // Height is calculated automatically progressBar : false // Hide the progress bar }); }); }); </script> </body> </html> Code: [Select] <?php include("config.php"); $host = $config['Site']['Host']; $username = $config['Site']['Username']; $password = $config['Site']['Password']; $database = $config['Site']['Database']; $name = $config['Site']['Name']; $favicon = $config['Site']['Favicon']; mysql_connect($host, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); function getVid() { $vID = $_GET['vID']; $sQuery = "SELECT * FROM vids WHERE id='$vID'"; $sResult = mysql_query($sQuery); while($row = mysql_fetch_array($sResult)) { $vID = $row['url']; } } ?> Above is the Global.php, and that's where the problem lies, whenever I try to insert the peices required, nothing happens and the video doesn't show. Could anybody please help?! the script here is the simplest progress bar ever.. what I want is for the value of the mutiplier (so how fast it loads) to be a php varible pulled from the users file <html> <head> <script type="text/javascript"> function progress() { if (document.images["bar"].width < 400) { document.images["bar"].width += 5; document.images["bar"].height = 5; } else { clearInterval(ID); } } var ID; window.onload = function() { ID = setInterval("progress();", 500); } </script> </head> <body> <img src="black.gif" name="bar" /> </body> </html> POSSIBLE? New to PHP/Java. Need some help!!! I need the textarea of a site to save what is entered into a text file. I also need javascript to use a pre-validate pop up box, if no data is entered. I can't get both of them to work at the same time. Below is my code. Code: [Select] <html> <head> <link rel="stylesheet" type="text/css" href="style.css"/> <script type="text/javascript"> <!-- <!CDATA[ function validateForm() { var x=document.forms["myForm"]["email"].value; var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Not a valid e-mail address"); return false; } } // ]]> --> </script> </head> <form name="form1" method="post" action="index2.php?saving=1"> <textarea name="data" cols="100" rows="10"> Username: Password: --------------------------------------------- </textarea> <br> </form> <form name="myForm" method ="post" action="index2.php?saving=1" onsubmit="return validateForm();"> <tr> <td align="right" width="10%"> Email: </td> <td><input type="text" name="email" id="email" size ="40" /> </td> </tr> <input type="submit" value="Submit"> </form> <p> <a href="index.html">Home</a> </html> PHP CODE: Code: [Select] <?php $saving = $_REQUEST['saving']; if ($saving == 1){ $data = $_POST['data']; $file = "data.txt"; $fp = fopen($file, "a") or die("Couldn't open $file for writing!"); fwrite($fp, $data) or die("Couldn't write values to file!"); fclose($fp); echo "Saved to $file successfully!"; } ?> I found a little javascipt online, and I wanted to play around with it. I'm trying to add a little php to it, I think I'm close to getting it, but when I click on the properties of the pictures that I want displayed, it has a bunch of extra garbage in it. So is the javascript reading something extra in the php script ? Here is the code. Code: [Select] <script language="JavaScript"> var j,d="",l="",m="",p="",q="",z="",KW_ARI= new Array() KW_ARI[KW_ARI.length]='<?php echo '<img src="trackimages/' . $row['new_pic'] . '" />'; ?>'; KW_ARI[KW_ARI.length]='<?php echo '<img src="trackimages/' . $row['new_pic'] . '" />'; ?>'; KW_ARI[KW_ARI.length]='<?php echo '<img src="trackimages/' . $row['new_pic'] . '" />'; ?>'; KW_ARI[KW_ARI.length]='<?php echo '<img src="trackimages/' . $row['new_pic'] . '" />'; ?>'; KW_ARI[KW_ARI.length]='<?php echo '<img src="trackimages/' . $row['new_pic'] . '" />'; ?>'; j=parseInt(Math.random()*KW_ARI.length); j=(isNaN(j))?0:j; document.write("<img name='seqSlideShow' src='"+KW_ARI[j]+"'>"); function seqSlideShow(t,l) { x=document.seqSlideShow; j=l; j++; if (j==KW_ARI.length) j=0; x.src=KW_ARI[j]; setTimeout("seqSlideShow("+t+","+j+")",t); } seqSlideShow(10000,0) </script> I'm trying to have a javascript confirm box pop up and confirm the intention to delete a record in a database. I think I'm having trouble calling the function within my PHP code, but not sure what exactly is wrong. The status bar shows something like "javascript:checkDelete(100, Title)" when I hover over the link and that seems right but nothing occurs when I click on it. Here is my code: Javascript Code: [Select] <script language="Javascript"> function checkDelete(b,Title){ var del=confirm("Are you sure you want to delete " + Title + " from the Database?"); if (del){ document.location="delete.php?mID=" + b + "&Title=" + Title; } } </script> PHP echo "<td><a href='Javascript:checkDelete(" . $row['mID'] . "," . $row['Title'] . ")'>"; echo "<img border=0 src='images/delete.gif'>" . "</a></td></tr>"; Anyone see my error? hi. i have a page B which has an image on it. When the page loads i want it to auto click on that image. I wrote the code below but it does not autoclick. can you please help? <script language="javascript"> function autoClick() { document.getElementById('thisLink').click(); } </script> <php> $visitpage = "http://mywebsitei.com/wp-content/uploads/12345.jpg"; <div style="text-align: center;" ######="setTimeout('autoClick();',3000);"> <a href=<?php echo $visitpage ?> rel="lightbox" > <img src=<?php echo $visitpage; ?> alt=""/></a> </div> </php> I would like to put an ad delay onto a webpage. No content shows up (complete white backgorund) until 30 seconds after viewing the ad. The ad would disappear and the content of the page would load up.
I need some help. I'm having trouble calling a javascript function from a php script Code: [Select] <?php include ('security.inc'); include ('head.inc'); echo ' <table class="menutable"> <tr> <td nowrap> <div id="sidemenu" style="display:block;"> <ul id="navbar">'; // database-driven menu groups // get the menu items and groups that this user has access to if (!isset($_SESSION['usergroupsin']) || $_SESSION['usergroupsin']==''){ $menurs=array(); } else { $sql="SELECT mg_name, mg_desc, mi_name, mi_desc, mi_link, mi_external_link, mgg_gr_id, mig_gr_id FROM tbl_menu_items INNER JOIN tbl_menu_groups ON mi_mg_id=mg_id AND mg_active='y' LEFT JOIN tbl_menu_groups_groups ON mgg_mg_id=mg_id AND mgg_active='y' LEFT JOIN tbl_menu_items_groups ON mig_mi_id=mi_id AND mig_active='y' WHERE ( mgg_gr_id IN (".$_SESSION['usergroupsin'].") OR mig_gr_id IN (".$_SESSION['usergroupsin'].") OR mi_secure='n' ) AND mi_active='y' AND mg_left_menu='y' GROUP BY mg_name, mg_desc, mi_name, mi_desc, mi_link, mi_external_link ORDER BY mg_sort, mi_sort"; $menurs=myload($sql); } $last_mg_name=''; if (count($menurs)>0){ foreach ($menurs as $m){ // show the group heading if we haven't already shown it if ($m['mg_name']<>$last_mg_name){ echo '<li><strong> <br>'.$m['mg_name'].'</strong></li>'; $last_mg_name=$m['mg_name']; } // determine whether this is a system link or not if ($m['mi_external_link']=='y'){ $thisurl=$m['mi_link']; } else { $thisurl=$config['system_url_root'].$m['mi_link']; } echo '<li><a title="'.$m['mi_desc'].'" href="'.$thisurl.'"><strong> - '.$m ['mi_name'].'</strong></a></li>'; } } echo ' </ul> </div> </td> [b]<input class="button" type="button" value="Hide Menu" onclick="setTable('sidemenu');return true">[/b] <td width="100%"> <div id="mainwindow"> <!-- BEGIN PAGE CONTENT --> '; ?> My javacscipt function is in the head.inc. I can post that if needed. The bolded part is what I'm having trouble with. Specifically, the onclick. Without that, my script works, if I have the onclick in there, I get a blank page. I'm trying to hide/show the div=sidemenu. If anybody has any suggestions, I'm open to it. well i got more questions since i started at javascript and now im currently practicing php my question is whats the equivalent of this lines of codes to php language? document.getElementById("txt1").value <input type="button" name="one" id="one" value="1" onclick="javascript:getvalue(1);"\> == well what i mean is can i pass value to php functions every time i click it? just like calculators OT: can some1 help me translating my js calcu codes to php ones? document.getElementById("txt1").value this is my main problem i cant display the buttons i click Hello all, i need your help on this.
I don´t know if it´s possible, and if possible, i don´t know how to do it.
I catch visitors country code using javascript in a variable called "country".
Then, i need to php include diferent files based on that country code, like:
if country == UK
include header_uk.php
else if country == US
include header_us.php
else if country == BR
include header_br.php
else
include header.php
I don´t know nothing about coding, this is just an example.
I don´t have another way of catching visitors country without javascript.
Is this possible?
Thanks in advance.
Edited by vascorama, 17 August 2014 - 01:49 PM. <html> <head> <script type=\"text/javascript\" src=\"swfobject.js\"></script> </head> <body> <script type=\"text/javascript\"> var multiplayer = new SWFObject(\"player.swf?xml=config.xml&player_skin=skin.swf\", \"multiVideoPlayer\", \"361\", \"283\", \"7\", \"#FFFFFF\", true); multiplayer.write(\"flashcontent\"); </script> </body> </html>Hi, Could anyone help make the above code run inside my PHP file? When loaded, I just get a blank page and I know the paths to files are correct. Thank you Edited by hexcode, 11 July 2014 - 01:19 PM. Hi guys... i want to do registration of text box which are created dynamically.. please help me how can i do registration? so I am not the best coder, and have been having a really hard time getting this devision in javascript. I would put it in html, but I use javascript to clear the page
<div id="test" style='position:fixed;bottom:0;left:0; height:76;background:darkorange;width:100%;'><h><object width="75" onclick="web()" height="75" data="img1.jpg"></object> <object width="75" onclick="mdoge()" height="75" data="img2.jpg"></object> <object width="75" onclick="word()" height="75" data="img3.jpg"></object></h></div>so that code above is the code I need to put in a document.write of something of equivalence. Is there any way to put this in javascript? thank you This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=306650.0 |