Connecting Tech Pros Worldwide Forums | Help | Site Map

Submit Button

Jimbo
Guest
 
Posts: n/a
#1: Jul 17 '05
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







Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Submit Button


Jimbo wrote:[color=blue]
> 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[/color]

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
PenguinsAnonymous
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Submit Button


Jimbo <Jim@garner21.freeserve.co.uk> wrote:[color=blue]
> 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?[/color]

<?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\">";
?>

[color=blue]
> Any help would be greatly appreciated[/color]
[color=blue]
> TIA[/color]
[color=blue]
> Jim[/color]

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! =-----
Andy Hassall
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Submit Button


On Wed, 12 Nov 2003 21:53:40 -0000, "Jimbo" <Jim@garner21.freeserve.co.uk>
wrote:
[color=blue]
>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[/color]

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)
PenguinsAnonymous
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Submit Button


Pedro Graca <hexkid@hotpop.com> wrote:[color=blue]
> Jimbo wrote:[color=green]
>> 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[/color][/color]
[color=blue]
> Why didn't the IF work?
> What was the error (if it was an error)?[/color]
[color=blue]
> <?php
> // ...
> if ($ok_to_output_the_submit_button) {
> echo '<input type="submit" value="Update"/>';
> }
> // ...
> ?>[/color]
[color=blue]
> --
> .sig[/color]

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! =-----
Eric Kincl
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Submit Button


Jimbo wrote:
[color=blue]
> 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[/color]

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.
Closed Thread