ricky spires Posted December 8, 2010 Share Posted December 8, 2010 hello. i have two functions that are not working because i cant seem to input the php and java correctly.. could someone help please. how do i put these lines into a function: 1 - function applyBox() { echo ' <div id="apply"> <h3><b><span class="arial18_GRN">Apply NOW</span> to become a<br>BusinessMobiles.com Affiliate</b></h3> <p class="applyText">Drive quality traffic to one of our<br>partners and get paid for it.</p> <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Apply','','image/callsToAction/applyButton2.jpg',1)"> <img src="image/callsToAction/applyButton1.jpg" class="applyButton" alt="Apply" name="Apply" width="137" height="36" border="0"></a> </div> '; } this part is not working: onMouseOver="MM_swapImage('Apply','','image/callsToAction/applyButton2.jpg',1)"> i can see that the ' is breaking it. i tried putting .'s but it didn't work : onMouseOver="MM_swapImage('.Apply.','..','.image/callsToAction/applyButton2.jpg.',1)"> 2 - this form: <div class="form"> <form name="Form" method="post" action="<?PHP echo $_SERVER['PHP_SELF']; ?>"> <input name="submit" type="hidden" value="submit" /></input> <input type="text" class="inputField" name="Uname" id="Uname" value="'.$Uname.'" onfocus="clearUname()"></input> <input type="text" class="inputField" name="PW" id="PW" value="'.$PW.'" onfocus="clearPW()"></input> <input type="image" class="submit" src="image/wrapper/submit.jpg" value="Submit" alt="login" width="36" height="20" border="0" /></input> </form> this part is not working : <form name="Form" method="post" action="<?PHP echo $_SERVER['PHP_SELF']; ?>"> i tried: <form name="Form" method="post" action="'.echo $_SERVER['PHP_SELF'].'"> but no luck. any suggestions ???? thanks ricky Link to comment https://forums.phpfreaks.com/topic/221023-trouble-using-php-and-java-inside-the-function/ Share on other sites More sharing options...
Buddski Posted December 8, 2010 Share Posted December 8, 2010 For the first problem you need to escape the single quotes in the HTML string using \ Here is an example: <?php echo '<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Apply\',\'\',\'image/callsToAction/applyButton2.jpg\',1)">'; As for your second issue.. im assuming that the code block is in an echo or print statement in which case your second attempt was close, you just dont need the echo in there. echo '<div class="form"> <form name="Form" method="post" action="'.$_SERVER['PHP_SELF'].'"> <input name="submit" type="hidden" value="submit" /></input> <input type="text" class="inputField" name="Uname" id="Uname" value="'.$Uname.'" onfocus="clearUname()"></input> <input type="text" class="inputField" name="PW" id="PW" value="'.$PW.'" onfocus="clearPW()"></input> <input type="image" class="submit" src="image/wrapper/submit.jpg" value="Submit" alt="login" width="36" height="20" border="0" /></input> </form>'; Also, it has just been bought to my attention that using PHP_SELF isnt a good idea, you should instead leave it blank action="" Link to comment https://forums.phpfreaks.com/topic/221023-trouble-using-php-and-java-inside-the-function/#findComment-1144418 Share on other sites More sharing options...
Anti-Moronic Posted December 8, 2010 Share Posted December 8, 2010 Should note that this is a terrible way of constructing a form. You should also not echo out the html from within the function. Instead, store the html in a variable and return the variable. Personally, I would weave into php from html to echo the username and password. Instead of.. <input type="text" class="inputField" name="Uname" id="Uname" value="'.$Uname.'" onfocus="clearUname()"></input> I would use: <input type="text" class="inputField" name="Uname" id="Uname" value="<?php echo $Uname;?>" onfocus="clearUname()"></input> Link to comment https://forums.phpfreaks.com/topic/221023-trouble-using-php-and-java-inside-the-function/#findComment-1144422 Share on other sites More sharing options...
ricky spires Posted December 8, 2010 Author Share Posted December 8, 2010 THANKS FOR YOUR REPLIES GUYS all works - very good Link to comment https://forums.phpfreaks.com/topic/221023-trouble-using-php-and-java-inside-the-function/#findComment-1144469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.