Try to follow me on this...
A user enters information into the addlisting.php form and submits. functions.php then captures these variables and $_post's them into new variables. For example:
within the functions.php file
$Property_Address = $_POST["Property_Address"];
The "Property_Address" (w/o the $ sign) is a variable from the addlisting.php file.
Also within the functions.php file is a variable/string called $contents
$contents = "<html>
<head>
<title>" . $Property_Address . "</title>
<link rel=\"stylesheet\" href=http://www.htmlforums.com/archive/index.php/\"../main_style.css\" type=\"text/css\"> " ... etc.
Basically $contents is a web page, in the form of a string, containing variables passed from the original addlisting.php form which is then saved to a .html file
So stepping back and looking at what's going on, A user enters information and a page is created with their form input onto a template and a specific file of theirs is created.
So my question is, when variables are called within the $contents string, they are displayed correctly in the final .html file, but how do I call a function from within the $contents string?It can be done the same way you would add a variable:$string = "Some Text" . yourfunction() . "Some text";
Whatever yourfunction() returns will be displayed in the string where it is called.Where do I define my function?
Can you define a function in a .php file? Or does it need to be in the .js file?php functions go into php files, javascript functions go into js files.
you could add the function any place you want in the file.I'm getting this error:
Fatal error: Call to undefined function: featureavail() in /mnt/web_h/d38/s15/b01d3464/www/RentVuFunctions.php on line 113
(The error in my code below would actually be on line 11 since I condensed it.)
The featureAvail() function is in a .js file that is loaded in the functions.php file. Although it is still not recognizing it. My functions.php file (condensed) looks like this:
<script language="Javascript" src=http://www.htmlforums.com/archive/index.php/"../rentVU.js"></script>
<?php
$Property_Address = $_POST["Property_Address"];
$contents = "<html>
<head>
<title>" . $Property_Address . "</title>
<link rel=\"stylesheet\" href=http://www.htmlforums.com/archive/index.php/\"../main_style.css\" type=\"text/css\">
<script language=\"Javascript\" src=http://www.htmlforums.com/archive/index.php/\"../rentVU.js\"></script>
</head>
<body>" . featureAvail() . "
</body>
</html>
?>
The featureAvail() function is defined within the rentVU.js file.you can't call a javascript function in php like that. you have to use javascript.So since I need to rewrite the php into javascript, my new question is how to pass all my form variables to a javascript file. I'm assuming I can't use $_POST anymore ($Property_Address = $_POST["Property_Address"];
).....and you can't pass php variables to javascript like you want.
what is your javascipt function?Well what I need to do now is (condensed) convert:
<?php
$Property_Address = $_POST["Property_Address"];
$contents = "<html>
<head>
<title>" . $Property_Address . "</title>
<link rel=\"stylesheet\" href=http://www.htmlforums.com/archive/index.php/\"../main_style.css\" type=\"text/css\">
<script language=\"Javascript\" src=http://www.htmlforums.com/archive/index.php/\"../rentVU.js\"></script>
</head>
<body>" . featureAvail() . "
</body>
</html>
?>
into a javascript equivalent.
The featureAvail() function is just a minor function I can work out. I'm more focused on being able to create and save the page the visitor (creates) with all the form variables using javascript rather than php before.For example, I have
<form action="javascript:createPage()">
Address:<input name="Property_Address" size="40" maxlength="100">
in my form.html file with the createPage() function declared in functions.js.
And in functions.js is:
function createPage() {
var propertyAddress = form.Property_Address;
var test = "test";
this.document.open();
this.document.write(propertyAddress.value);
this.document.close();
}
Do you see what I'm trying to do?so it seems you don't want to refresh the page? you want it to load the form variables right when they submit the form. right?
then do this
<body>
<script type="text/javascript"> featureAvail() </script>
</body>
that should work. but I am no javascript guru.
A user enters information into the addlisting.php form and submits. functions.php then captures these variables and $_post's them into new variables. For example:
within the functions.php file
$Property_Address = $_POST["Property_Address"];
The "Property_Address" (w/o the $ sign) is a variable from the addlisting.php file.
Also within the functions.php file is a variable/string called $contents
$contents = "<html>
<head>
<title>" . $Property_Address . "</title>
<link rel=\"stylesheet\" href=http://www.htmlforums.com/archive/index.php/\"../main_style.css\" type=\"text/css\"> " ... etc.
Basically $contents is a web page, in the form of a string, containing variables passed from the original addlisting.php form which is then saved to a .html file
So stepping back and looking at what's going on, A user enters information and a page is created with their form input onto a template and a specific file of theirs is created.
So my question is, when variables are called within the $contents string, they are displayed correctly in the final .html file, but how do I call a function from within the $contents string?It can be done the same way you would add a variable:$string = "Some Text" . yourfunction() . "Some text";
Whatever yourfunction() returns will be displayed in the string where it is called.Where do I define my function?
Can you define a function in a .php file? Or does it need to be in the .js file?php functions go into php files, javascript functions go into js files.
you could add the function any place you want in the file.I'm getting this error:
Fatal error: Call to undefined function: featureavail() in /mnt/web_h/d38/s15/b01d3464/www/RentVuFunctions.php on line 113
(The error in my code below would actually be on line 11 since I condensed it.)
The featureAvail() function is in a .js file that is loaded in the functions.php file. Although it is still not recognizing it. My functions.php file (condensed) looks like this:
<script language="Javascript" src=http://www.htmlforums.com/archive/index.php/"../rentVU.js"></script>
<?php
$Property_Address = $_POST["Property_Address"];
$contents = "<html>
<head>
<title>" . $Property_Address . "</title>
<link rel=\"stylesheet\" href=http://www.htmlforums.com/archive/index.php/\"../main_style.css\" type=\"text/css\">
<script language=\"Javascript\" src=http://www.htmlforums.com/archive/index.php/\"../rentVU.js\"></script>
</head>
<body>" . featureAvail() . "
</body>
</html>
?>
The featureAvail() function is defined within the rentVU.js file.you can't call a javascript function in php like that. you have to use javascript.So since I need to rewrite the php into javascript, my new question is how to pass all my form variables to a javascript file. I'm assuming I can't use $_POST anymore ($Property_Address = $_POST["Property_Address"];
).....and you can't pass php variables to javascript like you want.
what is your javascipt function?Well what I need to do now is (condensed) convert:
<?php
$Property_Address = $_POST["Property_Address"];
$contents = "<html>
<head>
<title>" . $Property_Address . "</title>
<link rel=\"stylesheet\" href=http://www.htmlforums.com/archive/index.php/\"../main_style.css\" type=\"text/css\">
<script language=\"Javascript\" src=http://www.htmlforums.com/archive/index.php/\"../rentVU.js\"></script>
</head>
<body>" . featureAvail() . "
</body>
</html>
?>
into a javascript equivalent.
The featureAvail() function is just a minor function I can work out. I'm more focused on being able to create and save the page the visitor (creates) with all the form variables using javascript rather than php before.For example, I have
<form action="javascript:createPage()">
Address:<input name="Property_Address" size="40" maxlength="100">
in my form.html file with the createPage() function declared in functions.js.
And in functions.js is:
function createPage() {
var propertyAddress = form.Property_Address;
var test = "test";
this.document.open();
this.document.write(propertyAddress.value);
this.document.close();
}
Do you see what I'm trying to do?so it seems you don't want to refresh the page? you want it to load the form variables right when they submit the form. right?
then do this
<body>
<script type="text/javascript"> featureAvail() </script>
</body>
that should work. but I am no javascript guru.