Help with buttons

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vampiro
Forum Newbie
Posts: 10
Joined: Mon Feb 27, 2012 10:32 am

Help with buttons

Post by vampiro »

Hi,

I have taken over updating our php system for customers after a collegue has left and we where using outdated php/apache software to run the system. :banghead: :banghead:
I am now trying to bring it more upto date and in line with current PHP standards.
He also didnt comment any of the code so i am kinda working in the dark (aha)
I am currently having issues with the following code.

Code: Select all

<input type="hidden" name="worksheet_id" value="<?php echo $worksheet["id"] ?>">
<input type="hidden" name="Estcomplete" value="<?php echo $worksheet["EstComplete"] ?>">
<input type="submit" name="updateworksheet" value="Update" onClick="javascript:checkCertificate()">
This code has the same issue as above:

Code: Select all

Add Job Note:<br><textarea name="jobnotes_notes" rows="4" cols="69"></textarea><br>
<input type="hidden" name="worksheet_id" value="<?php echo $worksheet["id"]; ?>">
<input type="submit" name="updatejobnotes" value="Add" onClick="javascript:checkCertificate();">
</form>
The code pops up a box and has say 3 days in the box which can be change to whatever number you want, it tracks how much work with have in for our IT team.
this was working under the older apache/php software but has no broken as i am slowly upgrading the system.

Thanks in advance for your help
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Help with buttons

Post by social_experiment »

Could you elaborate on "but has no broken"; the code you pasted looks ok (from a visual inspection) and it should still work even if your php version has changed
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
vampiro
Forum Newbie
Posts: 10
Joined: Mon Feb 27, 2012 10:32 am

Re: Help with buttons

Post by vampiro »

aha sorry mistyped.

The script does not pop up a prompt to ask how many days it should have.
I have just managed to track down a bit of code that is refered to in the orignal post:

Code: Select all

Function requestEstDays ()
{
    a = prompt('Please Enter an Estimated Time before Job Completion', form1.Estcomplete.value);

	if (a != null) {
		form1.Estcomplete.value = a;
		else form1.Estcomplete.value = false
		
	}
}
</script>

<!-- ///  end ask for est days !-->



<!-- ///  start check info on update !-->
<script>
function checkCertificate ()
{
	//checkCertificateProp();
	requestEstDays ();

}
</script>
If i comment out:

Code: Select all


	if (a != null) {
		form1.Estcomplete.value = a;
		else form1.Estcomplete.value = false
		
	}
i get the prompt but it does not alter the days vaule at the top of the page or anything else
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Help with buttons

Post by social_experiment »

Check the Error Console (or Web Console) when using firefox to see if any javascript errors are present; also view the source and see if this code contains a value

Code: Select all

<input type="hidden" name="Estcomplete" value="<?php echo $worksheet["EstComplete"] ?>">
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
vampiro
Forum Newbie
Posts: 10
Joined: Mon Feb 27, 2012 10:32 am

Re: Help with buttons

Post by vampiro »

when i use the web console i get:

[16:27:11.386] requestEstDays is not defined @ http://localhost:999/worksheet.php?work ... =12443:152
[16:27:11.403] POST http://localhost:999/worksheet.php?worksheet_id=12443 [HTTP/1.1 200 OK 78ms]
[16:27:11.462] Selector expected. Ruleset ignored due to bad selector. @ http://localhost:999/worksheet.php?work ... d=12443:52
[16:27:11.472] Unexpected end of file while searching for closing } of invalid rule set. @ http://localhost:999/worksheet.php?work ... d=12443:53
[16:27:11.482] syntax error @ http://localhost:999/worksheet.php?work ... =12443:137
[16:27:11.519] Use of getAttributeNode() is deprecated. Use getAttribute() instead. @ http://localhost:999/worksheet.php?worksheet_id=12443

and the error consle gets:

Error: requestEstDays is not defined
Source File: http://localhost:999/worksheet.php?worksheet_id=12443
Line: 152
Warning: Selector expected. Ruleset ignored due to bad selector.
Source File: http://localhost:999/worksheet.php?worksheet_id=12443
Line: 52
Warning: Unexpected end of file while searching for closing } of invalid rule set.
Source File: http://localhost:999/worksheet.php?worksheet_id=12443
Line: 53
Error: syntax error
Source File: http://localhost:999/worksheet.php?worksheet_id=12443
Line: 137, Column: 2
Source Code:
else form1.Estcomplete.value = false
Warning: Use of getAttributeNode() is deprecated. Use getAttribute() instead.
Source File: http://localhost:999/worksheet.php?worksheet_id=12443
Line: 0

Which refers to the code:

Code: Select all

Function requestEstDays ()
{
    a = prompt('Please Enter an Estimated Time before Job Completion', form1.Estcomplete.value);

        if (a != null) {
                form1.Estcomplete.value = a;
               else form1.Estcomplete.value = false
               
        }
}
</script>
and this just one line:

Code: Select all

else form1.Estcomplete.value = false
the Value is false when it is run, if the value is set to true it still errors.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Help with buttons

Post by social_experiment »

requestEstDays() has a syntax error which will stop any working; below is the updated function. I'm don't know if this will solve the problem but it will get you a step closer;

Code: Select all

Function requestEstDays()
{
    a = prompt('Please Enter an Estimated Time before Job Completion', form1.Estcomplete.value);

        if (a != null) {
                form1.Estcomplete.value = a;
        }
        else {
               // i forgot to add the ; at the end of this statement
                form1.Estcomplete.value = false;             
        }
}
Last edited by social_experiment on Tue Mar 27, 2012 3:45 am, edited 1 time in total.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
vampiro
Forum Newbie
Posts: 10
Joined: Mon Feb 27, 2012 10:32 am

Re: Help with buttons

Post by vampiro »

Hi thanks for your help

I have put the updated code in and this is what error/web console now give as errors

Error console:

Error: requestEstDays is not defined
Source File: http://localhost:999/worksheet.php?worksheet_id=12356
Line: 153
Warning: Selector expected. Ruleset ignored due to bad selector.
Source File: http://localhost:999/worksheet.php?worksheet_id=12356
Line: 52
Warning: Unexpected end of file while searching for closing } of invalid rule set.
Source File: http://localhost:999/worksheet.php?worksheet_id=12356
Line: 53
Error: missing ; before statement
Source File: http://localhost:999/worksheet.php?worksheet_id=12356
Line: 131, Column: 9
Source Code:
Function requestEstDays ()

Web console:

[09:00:30.105] requestEstDays is not defined @ http://localhost:999/worksheet.php?work ... =12356:153
[09:00:30.160] POST http://localhost:999/worksheet.php?worksheet_id=12356 [HTTP/1.1 200 OK 73ms]
[09:00:30.237] Selector expected. Ruleset ignored due to bad selector. @ http://localhost:999/worksheet.php?work ... d=12356:52
[09:00:30.250] Unexpected end of file while searching for closing } of invalid rule set. @ http://localhost:999/worksheet.php?work ... d=12356:53
[09:00:30.262] missing ; before statement @ http://localhost:999/worksheet.php?work ... =12356:131

I have tried putting the ";" into the statment but to now avail, the php page refreshes and says that it has updated buit does not give me the prompt still
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Help with buttons

Post by social_experiment »

vampiro wrote:Error: requestEstDays is not defined
I updated my code snippet to include a missing ';'.

The functions, requestEstDays() and checkCertificate() are they embedded (i see you pasted <script> tags) or inside an external javascript file?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
vampiro
Forum Newbie
Posts: 10
Joined: Mon Feb 27, 2012 10:32 am

Re: Help with buttons

Post by vampiro »

I have updated the code on the page and it still does not propmt and error console still gives:

Error: requestEstDays is not defined
Source File: http://localhost:999/worksheet.php?worksheet_id=12356
Line: 152
Error: missing ; before statement
Source File: http://localhost:999/worksheet.php?worksheet_id=12356
Line: 129, Column: 9
Source Code:
Function requestEstDays()

web console:

[10:12:08.836] requestEstDays is not defined @ http://localhost:999/worksheet.php?work ... =12356:152
[10:12:08.876] POST http://localhost:999/worksheet.php?worksheet_id=12356 [HTTP/1.1 200 OK 58ms]
[10:12:08.933] missing ; before statement @ http://localhost:999/worksheet.php?work ... =12356:129

the functions, requestEstDays() and checkCertificate() are embedded in the code of the page, not in an external file.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Help with buttons

Post by social_experiment »

Could you paste the code for lines 129 and 152;
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
vampiro
Forum Newbie
Posts: 10
Joined: Mon Feb 27, 2012 10:32 am

Re: Help with buttons

Post by vampiro »

Can do one better,

here is a pastbin link to the entire page that i am having the issue with.

http://pastebin.com/Shzxqcks

Again thank you for your help, it is much appreciated
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Help with buttons

Post by social_experiment »

Not sure if this is the solution but if the word "Function" is used it causes an error with the same results;

Code: Select all

Function requestEstDays()
 // change to
function requestEstDays()
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
vampiro
Forum Newbie
Posts: 10
Joined: Mon Feb 27, 2012 10:32 am

Re: Help with buttons

Post by vampiro »

Many many thanks... changing the function to a small f fixed the issue.

again thnaks for your help, much appreciated
Post Reply