Jump to content

[SOLVED] Prompt Help!!!


neverett

Recommended Posts

I'm having a bit of trouble working on a do-while loop for a prompt box.  I'm looking for a sample piece of code that shows how you can require input on a prompt [using a do-while].  I really only need the conditions for the while portion.  I keep making an infinite loop.  So if they press cancel or if they type nothing [an empty string] then I want it to pop the prompt up again and again until they enter a string.  Thank you for any help in advance.

 

NE

Link to comment
https://forums.phpfreaks.com/topic/86210-solved-prompt-help/
Share on other sites

Any ideas on how to get something like this to work?  Post back if you have any questions.

 

$details = "";
if($newstatus == 4){
	$details = echo "
		<script type=\"text/javascript\">
			var det = \"\";
			while(det == \"\"){
				det = prompt(\"Please detail the changes\", \"\");
			}
			return det;
		</script>
	";
}

 

This is the error I get...

 

Parse error: parse error, unexpected T_ECHO in /home/content/t/r/a/tracpr/html/members/changestatus.php on line 16

 

Line 16 is:

 

$details = echo "
		<script type=\"text/javascript\">
			var det = \"\";
			while(det == \"\"){
				det = prompt(\"Please detail the changes\", \"\");
			}
			return det;
		</script>
	";

 

Thanks in advance for any help you may have!!!

 

NE

Link to comment
https://forums.phpfreaks.com/topic/86210-solved-prompt-help/#findComment-440620
Share on other sites

try this and see if this corrects the error:

 

<?php

$details="";// you need to declare this and not just leave it empty

if($newstatus == 4){
	$details="<script type=\"text/javascript\">
			var det = \"\";
			while(det == \"\"){
				det = prompt(\"Please detail the changes\", \"\");
			}
			return det;
		</script>";
}

echo "$details";


?>

Link to comment
https://forums.phpfreaks.com/topic/86210-solved-prompt-help/#findComment-441506
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.