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
Share on other sites

do-whiles - in my book - are VERY VERY BAD... they are very easy to infinite loop and theres really no need...

 

this should work FAR easier, and faster...

 

<script>
var blah='';
while(blah==''){
var blah=prompt('please enter your name');
}
</script>

Link to comment
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.