Submit Button

This is a discussion on Submit Button within the PHP Language forums, part of the PHP Programming Forums category; I am trying to right a script so that the "submit button" only appears when certain criteria has ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-12-2003
Jimbo
 
Posts: n/a
Default Submit Button

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






Reply With Quote
  #2 (permalink)  
Old 11-12-2003
PenguinsAnonymous
 
Posts: n/a
Default Re: Submit Button

Jimbo <Jim@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! =-----
Reply With Quote
  #3 (permalink)  
Old 11-12-2003
Pedro Graca
 
Posts: n/a
Default Re: Submit Button

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
Reply With Quote
  #4 (permalink)  
Old 11-12-2003
PenguinsAnonymous
 
Posts: n/a
Default Re: Submit Button

Pedro Graca <hexkid@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! =-----
Reply With Quote
  #5 (permalink)  
Old 11-12-2003
Andy Hassall
 
Posts: n/a
Default Re: Submit Button

On Wed, 12 Nov 2003 21:53:40 -0000, "Jimbo" <Jim@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 (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Reply With Quote
  #6 (permalink)  
Old 11-14-2003
Eric Kincl
 
Posts: n/a
Default Re: Submit Button

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0