WordPress.org

Ready to get started?Download WordPress

Forums

php and javascript insert in post (1 post)

  1. donking13
    Member
    Posted 1 year ago #

    Hi good day,

    my code is working on a static page without any wordpress code in them. but then I want it to include in a page. So I use the "allow PHP in post" plugin and "insert javascript and CSS" plugin.

    here's my problem:
    -the php executes but it doesn't print the right answer
    -the javascript is not functioning well also. what is suppose to do is when the user choose the redesign, the form changes (hiding the visible form and shows the form for redesign)

    here's the code for javascript:

    <script type="text/javascript">
    function newWeb()
    	{
    		var newweb = document.getElementById('services');
    		formbudget.style.visibility = 'hidden';
    		formnew.style.visibility = 'visible';
    
    	}
    
    function redesign()
    {
    		var newweb = document.getElementById('services');
    		formbudget.style.visibility = 'visible';
    		formnew.style.visibility = 'hidden';
    
    }
    
    function getValueSelectHandler(select)
    {
    	if (select.value == 1)
    		{
    			newWeb();
    		}
    	else if(select.value == 2)
    	{
    		redesign();
    	}
    }
    </script>

    the code for php:

    <?php
    $page = $_POST["pages"];
    $purpose = $_POST["purpose"];
    $domain = $_POST["domain"];
    $qoute = 0;
    
    	function myPage()
    	{
    	global $page,$qoute;
    
    		if($page <= 5)
    		{
    			$qoute = $qoute + 3000;
    		}
    		else
    			{
    			$qoute = $qoute + 4000;
    			}
    	}
    
    	function myPurpose()
    	{
    	global $purpose,$qoute;
    
    		if($purpose == 5)
    		{
    			$qoute = $qoute + 3500;
    		}
    		else
    		{
    
    		$qoute = $qoute + 0;
    
    		}		
    
    	}
    
    	function myhostDom()
    	{
    	global $domain,$qoute;
    
    		if($domain == 1)
    		{
    			$qoute = $qoute + 3000;
    		}		
    
    		else if($domain == 2)
    		{
    			$qoute = $qoute + 0;
    		}
    
    	}
    
    	if(isset($_POST['submit1']))
    		{
    
    	myPage();
    	myPurpose();
    	myhostDom();
    	echo "<html>";
    	echo "<div id='total'> total of $qoute pesos
    		  <br/><br/>
    		  Do you want to continue? contact us. Use the text area below.
    		  </div>
    		  <br/>
    		  ";
    
    		}
    ?>

    the html structure

    <form id="mainform" action="" method="post">
    Services : <BLOCKQOUTE><select id="services" name="services" onChange="getValueSelectHandler(this)">
    					<Option Value="0" selected="selected" >--Select--</option>
    					<Option Value="1" >New Website</option>
    					<Option Value="2">Redesign/Update</option>
    					</select></BLOCKOQOUTE>
    
    <div id="formbudget">
    Budget: <input id="budget" type="number" name="budget">
    
    What do you want us to do?
    
    		<textarea name="bigtext">
    
            </textarea>
    
    <input id="submit" type="submit" value="send" name="submit1">
    </div>
    
    <div id="formnew">
    
    Hosting & Domain: 	<BLOCKQOUTE>
    					<select id="domain" name="domain">
    					<Option Value="0">--Select--</option>
    					<Option Value="1">Add Hosting and Domain</option>
    					</select>
                        </BLOCKOQOUTE>
    
    How many pages: <input type="number" name="pages">
    
    Purpose of the website: 
    
    <blockquote>
    						<input type="checkbox"  name="purpose" value="1"> Blog
    						<input type="checkbox"  name="purpose" value="2"> Business
    						<input type="checkbox"  name="purpose" value="3"> Community
    						<input type="checkbox"  name="purpose" value="4"> Portfolio
    						<input type="checkbox"  name="purpose" value="5"> Ecommerce
    
    </blockquote>
    Category of the website: 
    
    <blockquote><select name="categories">
    						<Option Value="0">--Select--</option>
    						<option Value="1">Gaming</option>
    						<option Value="2">Sports</option>
    						<option Value="3">Food/Restaurant</option>
    						<option Value="4">Health Care</option>
    						<option Value="5">Events/Parties</option>
    						<option Value="6">Clothing/Shopping/Apparel</option>
    						<option Value="7">Travel</option>
    						<option Value="8">Cars</option>
    						<option Value="9">Movies</option>
    						<option Value="10">School/Learning</option>
                         </select>
    
    </blockquote>
    <input id="submit" type="submit" value="get a qoute" name="submit1">
    </div>
    
    </form>

    link: http://www.websitealfred.com/contact-us/

Topic Closed

This topic has been closed to new replies.

About this Topic