hi,

i want to alert (javascript dialog) after user clicks the submit button, then process it with php and then show the alert after the body has reloaded (same body after post, just calling the same page.

the easy thing to be done, but i'm going mad with it, is to show an alert saying 'blank' if nothing was posted (the input is empty) or saying 'not blank' if something was written in it.

cant' get it to work with firefox. the alert is just showing a dialog with no text, and in the place where the text should be, there's a 'hole' (transparent) through which i can see the underneath web.

please help me before i get completely mad!!!
i've tryed lots of things, i need this structure as it is.
i've tryed an automatic alert, which also fails.
tryed syntax change, add language="javascript", double and simple quotes, html strict and transitional, etc etc...

must be something so easy i'm missing it!!!
thanks for helping me!

here is the code:

<?
if ($_POST)
    {
    if (empty($_POST['testabc'])) $msg='<script type="text/javascript">alert("BLANK");</script>';
    else $msg='<script type="text/javascript">alert("NOT BLANK");</script>';
    }
?>
<html><head></head><body>
<table>
    <tr>
        <td>
            <form id="finfo" method=POST>
                <input type="text" name="testabc">
                <input type="submit" value="info">
            </form> 
        </td>
    </tr>
</table>
<script type="text/javascript">alert("auto");</script>
<? echo $msg; ?>
</body></html>

thanks for your time helping!
take care
g

do no submit form to php before validating with javascript. look at the following code carefully.

<html><head>
<script language="javascript">
function validate()
{
    if (document.finfo.testabc.value=='')	
    {
		alert('enter some value');
		return false;// this will not allow form to submit
	}
	return true;
}
</script>
</head><body>
<table>
<tr>
<td>
<form id="finfo" name="finfo" method=POST onsubmit='return validate()'>
<input type="text" name="testabc">
<input type="submit" value="info">
</form> 
</td>
</tr>
</table>


</body></html>

dude! works awesome! thanks!
anyway, i need to check the data with server data, so it would be much better if it was in the structure after post. i guess the problem with the alert is related to post. :-( any ideas?
i'll try to do it this way, passing the server data on a hidden or something, but may not be possible, as probably i will need the form data, and this was just a structure test.
is there any way to get the alert working after a post?
thanks anyway, though!. works fluid!
have a nice day as here! hug!

i have just realized i need to alert AFTER the post :-( so the code you suggest won't fit, though works. but, after the post, in the code i published, i assign a <script>alert</scritp> to a php var ($msg) and after completion of the page, i display it.
it doesnt work, anyway. it just appears as a dialog with no text, and where the written text ('ok, success') or whatever, doesnt appear. just blank or a hole through which i can see the underneath web (testing with pictures).
works fine in ie, but cant get it to work in firefox. i need this structure to be as is (PHP POST and then display the alert later if needed).
any ideas?? missing something??? thanks for your support!
have a nice day!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.