Link to home
Start Free TrialLog in
Avatar of sysflinx
sysflinx

asked on

How do i use the elseif code to choose from to output options?

Im tryin to post results from a form input radio buttons page to the next page which chooses from two output methods depending on which radio button was selected. Please include code example or revised code to make code snippet working.

Thanks,
SYSFlinx
<div id="Platform11" style="position:absolute; left:33px; top:357px; width:128px; height:221px; z-index:16">
if ($_POST['radiobutton'] == 'a') {
<br>
  <div align="left" class="style12">
 
 
    <p>&nbsp;</p>
 
    <p align="center" class="style21"><a href="keyword1.htm"><?php echo $_POST['keyword1']; ?></a> </p>
    <br><p align="center" class="style21"><a href="keyword2.htm"><?php echo $_POST['keyword2']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword3.htm"><?php echo $_POST['keyword3']; ?></a> </p>
    <br><p align="center" class="style21"><a href="keyword4.htm"><?php echo $_POST['keyword4']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword5.htm"><?php echo $_POST['keyword5']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword6.htm"><?php echo $_POST['keyword6']; ?></a> </p>
    <br><p align="center" class="style21"><a href="keyword7.htm"><?php echo $_POST['keyword7']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword8.htm"><?php echo $_POST['keyword8']; ?></a></p> 	
 
    <p align="center" class="style21">&nbsp;</p>
}
</div>
 
  elseif ($_POST['radiobutton'] == 'b') {
 
	<script type="text/javascript"><!--
google_ad_client = "<?php echo $_POST['leftmenuad']; ?>";
/* 180x90, created 3/8/08 */
google_ad_slot = "7902173316";
google_ad_width = 130;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
}  </div>

Open in new window

Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

sysflinx,

What is your problem?

The If and ElseIf are meant to be done by server script, right?  You seem to be mixing them though.  You have no server script tags (except for in the echo parts) but $_POST[] is not Javascript.  Please elaborate on what the code should be doing.  Also which is Javascript and which needs to come from the server?  If the problem is just Javascript then show us the HTML source (i.e. from the browser) not the server script.

Let me know if you have any questions or need more information.

b0lsc0tt
Use the code below. Make sure you copy and paste from here. NOTE: you are missing the <?php and ?> tags. Also, your radio buttons need to be named "radiobutton". EX:
<input type="radio" name="radiobutton" value="a"/>
<input type="radio" name="radiobutton" value="b"/>
<div id="Platform11" style="position:absolute; left:33px; top:357px; width:128px; height:221px; z-index:16">
<?php
if ( strval($_POST['radiobutton']) == 'a') {
?>
<br>
  <div align="left" class="style12">
 
 
    <p> </p>
 
    <p align="center" class="style21"><a href="keyword1.htm"><?php echo $_POST['keyword1']; ?></a> </p>
    <br><p align="center" class="style21"><a href="keyword2.htm"><?php echo $_POST['keyword2']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword3.htm"><?php echo $_POST['keyword3']; ?></a> </p>
    <br><p align="center" class="style21"><a href="keyword4.htm"><?php echo $_POST['keyword4']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword5.htm"><?php echo $_POST['keyword5']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword6.htm"><?php echo $_POST['keyword6']; ?></a> </p>
    <br><p align="center" class="style21"><a href="keyword7.htm"><?php echo $_POST['keyword7']; ?></a></p>
    <br><p align="center" class="style21"><a href="keyword8.htm"><?php echo $_POST['keyword8']; ?></a></p>       
 
    <p align="center" class="style21"> </p>
<?php
}
?>
</div>
<?php
  elseif (strval($_POST['radiobutton']) == 'b') {
?> 
      <script type="text/javascript"><!--
		google_ad_client = "<?php echo $_POST['leftmenuad']; ?>";
		/* 180x90, created 3/8/08 */
		google_ad_slot = "7902173316";
		google_ad_width = 130;
		google_ad_height = 90;
	//-->
	</script>
	<script type="text/javascript"
		src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
	</script>
<?php
}  
?>
</div>

Open in new window

Avatar of sysflinx
sysflinx

ASKER

I get error:
Parse error: syntax error, unexpected T_ELSEIF in /home/lprub/public_html/page2.php on line 161




PLEASE advise?

Thanks,
SYSFlinx
line 161: 
 
  elseif (strval($_POST['radiobutton']) == 'b') {

Open in new window

Why did you open a new question for that at http:Q_23225960.html if it is related to this??  You can't duplicate questions.

If that is a separate issue from the question here then the experts in the other question will help you with it.  Let us know what other questions or help you need for your question here.

If they are the same then it is still probably better to work on it there (pretend they are different).  Please do not do this again but there is nothing to be gained by duplicating work, etc.  If fixing that still means you have a question or need help with this then we can continue to work on it here.

Let me know if you have a question.

bol
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bravo!
Hail GURU!!!!
Thanks ALOT,
SYSFlinx
>>Hail GURU!!!!
You mean Hielo!!! There a lot of Gurus here. Guru is the rank :) Glad to help. Please close this problem. If you need further assistance, open a different problem.