I want to make code for making comments and share it to others.
When I run this code and write a comment it prints nothing.
Note: I got this code from a tutorial on youtube.
<html>
<head>
<title>hesham</title>
</head>
<script src="jquery-1.6.1.min.js" type="text/javascript"></script>
<script type="text/javascrpt">
function get()
{
var input = $('#cmt').val();
$('#an').prepend(input);
};
</script>
<body>
<form name="frm">
<input type="text" name="cmt" id="cmt" /><input type="button" value="post" onclick="get()" />
</form>
<div id="an" style="width:300px">
</div>
</body>
</html>
The problem is with this:
<script type="text/javascrpt">
^-- // missing the "i"
It's mispelled, a slight typo.
Change it to:
<script type="text/javascript">
and it will work.
(tested)
You could also place your jQuery in <head></head> yet, my test worked either way.
Related
To start with: My web coding skills are nearly to non existent, I just did a bit of HTML ages ago...
And my first steps with php are just made today.
My goal is: Having a color picker and sending the picked value as an argument to an python script.
I managed to use the jscolor picker libary (http://jscolor.com/examples/) and I've been also able to run the python scripts with an (color) argument from php.
My problem is now:
How do I submit the color string (hex-str) to the exec command (LED_color)?
<?php
$LED_color="FFFFFF";
$LED_color=escapeshellarg($LED_color);
if (isset($_POST['button']))
{
$LED_color = $_REQUEST['hex-str'];
echo shell_exec("sudo /home/pi/LEDscripts/color-by-arg.py $LED_color");
}
?>
<html>
<head>
<title>Basic usage</title>
</head>
<body>
<div style="position:absolute; left:280px; top:10px;">
toString = <span id="hex-str"></span><br />
</div>
<script src="jscolor.js"></script>
Color: <input class="jscolor {closable:true,closeText:'Close me!',onFineChange:'update(this)'}" value="000000">
<script>
function update(picker) {
document.getElementById('hex-str').innerHTML = picker.toString();
}
</script>
<form method="post">
<p>
<button name="button">Submit color</button>
</p>
</form>
</body>
</html>
Your color picker input needs a name attribute to match your PHP code, and also needs to be inside the <form> element.
<?php
if (!empty($_POST["hex-str"])) {
$LED_color = escapeshellarg($_POST["hex-str"]);
echo shell_exec("sudo /home/pi/LEDscripts/color-by-arg.py $LED_color");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Basic usage</title>
<script src="jscolor.js"></script>
</head>
<body>
<form method="post">
<p>
Color:
<input type="text" name="hex-str" value="000000" class="jscolor" data-jscolor="{closable:true,closeText:'Close me!',onFineChange:'update(this)'}"/>
toString = <span id="hex-str-display"></span>
</p>
<p>
<button type="submit">Submit color</button>
</p>
</form>
<script>
function update(picker) {
document.getElementById('hex-str-display').innerHTML = picker.toString();
}
</script>
</body>
</html>
I have this url in classic asp:"http:/blablabla/123.asp?id=1293". My question, is there a way to pass the id number to a external php script without using the form and submit, or that is only way to do it??
My data.php script:
<?php
$xxx = $_POST["xxx"];
//... some code
$gantt->render_complex_sql("SELECT * FROM gantt_tasks WHERE something = '".$xxx."'" , "id", "start_date,duration,text,progress,parent","");
?>
My "123.asp?id=1293" page:
<html>
<head>
// .. scripts and title
</head>
<body>
<form id="form1" method="post" action="data.php">
<input type="hidden" name="xxx" value="Request.QueryString("id")" />
</form>
<div id="gantt_here" style='width:100%; height:100%;'></div>
<script type="text/javascript">
gantt.init("gantt_here");
gantt.load("data.php");
</script>
</body>
</html>
And i dont want to use the "Response.Redirect" page either.
You can do this:
UPDATE:
gantt.load('data.php?id=<%= Request.QueryString("id") %>');
But it sounds very strange using old asp files and php files in the same project.
I have an html page which contains a div that displays the html from an external php file.
It works great until I add a DOCTYPE declaration to the html page. The page continues to function, except the external content does not appear in the div.
<!DOCTYPE HTML>
<html dir="ltr" lang="en-US">
<head>
<title>Test Page</title>
<!--meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" src="./inc/jquery.js"></script>
<script type="text/javascript">
function getinfo()
{
$.post('prodinfo.php', { prodcode: prodcodeform.prodcodevar.value},
function(output)
{
$('#prodinfo').html(output).show;
});
}
function hideinfo()
{
$('#prodload').hide();
$('#openprodinfo').show();
}
function showinfo()
{
$('#prodload').show();
$('#openprodinfo').hide();
}
</script>
</head>
<body>
<input style="position:relative;" type="button" class="button" id="openprodinfo" title="Open" value="INFO" onclick="showinfo();">
<DIV id="prodload" style="position:absolute;margin-left:auto;margin-right:auto;display:none;text-align:center;background-color:#000000;z-index:200;border:1px solid #4e443b;">
<div id="prodinfo" style="position:relative;display:block;top:0;width:1000px;height:820px;background-color:#ffffff;margin-left:auto;margin-right:auto;">
</div>
<form name="prodcodeform">
<input type="text" readonly="readonly" id="prodcodevar" name="prodcodevar" value="nil" >
</form>
<div ID="prodinfobutton" style="position:relative;">
<input style="position:relative;" type="button" class="button" id="closeprodinfo" title="Close" value="CLOSE" onclick="document.getElementById('prodcodevar').value='nil'; hideinfo(); ">
</div>
<input type="button" id="button001" value="ONE" onclick="document.getElementById('prodcodevar').value='item1'; getinfo();">
<input type="button" id="button002" value="TWO" onclick="document.getElementById('prodcodevar').value='item2'; getinfo();">
</DIV>
</body>
</html>
You are switching to Standards mode, so your browser is no longer playing the game of being compatible with Internet Explorer 4.
prodcodeform.prodcodevar.value will error because prodcodeform is undefined.
You don't get a global variable for every element with an id or name in a document.
Change:
<form name="prodcodeform">
To
<form id="prodcodeform" method="post" action="prodinfo.php">
… and make it do something sane when a non-Ajax request gets posted (move it so it is around the buttons, make them submit buttons, and cancel the default event if the JS succeeds).
Then add:
var prodcodeform = document.getElementById('prodcodeform');
before you try to use the variable.
You started your body with </body> instead of <body>.
In a form I have an <iframe> that contains a PHP file (editor.php). This PHP file contains an HTML form.
Well, when I do a "submit form", I call the same PHP file, for example main.php.
When I press the submit button, I have "onclick method" that it calls a Javascript function inside editor.php. This function executes the form.
My problem is that main form is executed correctly but the second form is not.
In the second loop of the form of editor.php receives nothing.
**Check this way it will work as you expected**
//main.php
<html>
<head>
<script type="text/javascript">
function validateMain()
{
alert('main');
}
function validateSub()
{
alert('sub');
}
</script>
</head>
<body>
<form id="main" onsubmit="return validateMain();">
<input type="text" name="first" id="first"/>
<input type="submit" value="Submit Main"/>
</form>
<iframe name="ifr-form" id="ifr-form" src="test.html"></iframe>
</body>
</html>
//test.html the second form included through iframe
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>
<form id="sub" onclick="return window.top.validateSub();">
<input type="text" name="first" id="second"/>
<input type="button" value="Submit Sub" />
</form>
</div>
</body>
</html>
you must check if php and iframe are compatible, as far as i Know I don't think that frames and php gives any output, hope this helps.
please could someone let me see some examples? Really Thank You.
I found something but now i have another problem:
for example i have the following javascript inside a tpl:
<script src="http://www.domain.com/script.js" type="text/javascript"></script>
<div id="youtubeDiv"></div>
<script type="text/javascript">
insertVideos({'block':'youtubeDiv','q':'keyword','type':'search','results':8,'order':'most_relevance','player':'embed','layout':'thumbnails'});</script>
between {literal}{/literal} to let it work... but how to replace the "keyword" with the smarty variable {$product.name} ???
ok, solved... in place of 'keyword':
'{/literal}{$mySmarty_variable}{literal}'
<form onsubmit="insertVideos({'block':'youtubeDivSearch','type':'search','q':document.getElementById('ytSearchField').value,'results': 20,'order':'most_relevance','layout':'thumbnails'}); return false;">
<input id="ytSearchField" type="text" />
<input type="submit" value=" Search " />
</form>
<div id="youtubeDivSearch"></div>
<script src="http://www.yvoschaap.com/ytcp.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js" type="text/javascript"></script>
<div id="youtubeDiv"></div>
<div id="youtubeDivUser"></div>
<script>insertVideos({'block':'youtubeDivUser','type':'user','q':'','results': 20,'layout':'thumbnails','player':'embed','imgstyle':'3px solid #333'});</script>