By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

Submit Button

P: n/a
I am trying to right a script so that the "submit button" only appears when
certain criteria has been met. I have tried putting it in an IF statement,
without any luck. Maybe a function would allow me to do this?

<input type="Submit" value="Update">

Any help would be greatly appreciated

TIA

Jim


Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jimbo wrote:
I am trying to right a script so that the "submit button" only appears when
certain criteria has been met. I have tried putting it in an IF statement,
without any luck. Maybe a function would allow me to do this?

<input type="Submit" value="Update">

Any help would be greatly appreciated


Why didn't the IF work?
What was the error (if it was an error)?

<?php
// ...
if ($ok_to_output_the_submit_button) {
echo '<input type="submit" value="Update"/>';
}
// ...
?>

--
..sig
Jul 17 '05 #2

P: n/a
Jimbo <Ji*@garner21.freeserve.co.uk> wrote:
I am trying to right a script so that the "submit button" only appears when
certain criteria has been met. I have tried putting it in an IF statement,
without any luck. Maybe a function would allow me to do this?
<?php
// this way no button
if(criteria) echo "<input type=\"Submit\" value=\"Update\">";
?>

<?php
// this way grey button
if(criteria) $xtra="disabled";
echo "<input type=\"Submit\" {$xtra} value=\"Update\">";
?>

Any help would be greatly appreciated TIA Jim


There is a disable parameter for I think 'input'
that would grey the button rather than it not
be there. A clear indication in UI terms of
incompletion.
Does that sound like what you want?
Otherwise don't output that part of the form and
it won't appear at all.
(ie the input line you show above as I have mod it)
That's not nice though :)

Hope this helps you.
-Walt

--
Reply to innkeepATcapitalDOTnet to email questions.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #3

P: n/a
On Wed, 12 Nov 2003 21:53:40 -0000, "Jimbo" <Ji*@garner21.freeserve.co.uk>
wrote:
I am trying to right a script so that the "submit button" only appears when
certain criteria has been met. I have tried putting it in an IF statement,
without any luck. Maybe a function would allow me to do this?

<input type="Submit" value="Update">

Any help would be greatly appreciated


Not enough information really; it sounds to me like you're not after a PHP
solution though.

Since the only way to make PHP aware of new information is to at least do a
page request, and probably as a result of submitting a form, then you can't
change any conditions if you don't have a submit button in the first place.

Are you looking for something that can reveal a submit button when certain
fields have all been filled in on the client browser? If so, you need to ask in
a JavaScript group.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #4

P: n/a
Pedro Graca <he****@hotpop.com> wrote:
Jimbo wrote:
I am trying to right a script so that the "submit button" only appears when
certain criteria has been met. I have tried putting it in an IF statement,
without any luck. Maybe a function would allow me to do this?

<input type="Submit" value="Update">

Any help would be greatly appreciated
Why didn't the IF work?
What was the error (if it was an error)? <?php
// ...
if ($ok_to_output_the_submit_button) {
echo '<input type="submit" value="Update"/>';
}
// ...
?> --
.sig


I get the idea he might not understand the concept
of server side and what echo is doing yet. ie that
you are dynamically emitting the html that client
side will see inside the <?php ... ?>
hopefully these are lightbulbs :)
-Walt

--
Reply to innkeepATcapitalDOTnet to email questions.
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 17 '05 #5

P: n/a
Jimbo wrote:
I am trying to right a script so that the "submit button" only appears
when certain criteria has been met. I have tried putting it in an IF
statement, without any luck. Maybe a function would allow me to do this?

<input type="Submit" value="Update">

Any help would be greatly appreciated

TIA

Jim


You definatly want JavaScript here. Even though this is a PHP group, I'll
give you the JS for free

<form name="inputform">
<input type="text" name="field1" value="" onblur="javascript:validate();" />
<input type="text" name="field2" value="" onblur="javascript:validate();" />
<input type="submit" name="submit" value="Submit" disabled
onclick="javascript:disable();" />
</form>
<script language="JavaScript">
function validate(){
if(document.inputform.field1.value != ""){
if(document.inputform.field2.value != ""){
document.inputform.submit.disabled = false;
}
}
}
function disable(){
document.inputform.submit.disabled = true;
document.inputform.submit.value = "Please wait... Form is being
submitted.";
}
</script>
Obviously you will have to edit your form/javascript validation for your
page, but this is the basic idea of what you need to do. With this, it
will be impossible for the user to push the submit button until everything
is validated. It will also disable the submit button after the user clicks
it to prevent double submitting by impatient users.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.