Jump to content


Photo

php in java script or another way to correct my issue


  • Please log in to reply
5 replies to this topic

#1 predator12341

predator12341
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts
  • LocationCheshunt, Hertfordshire, England

Posted 19 April 2006 - 01:01 PM

right i have this code below and what it does is if the ok button is pressed on the java pop up it should carry out the code but i dont no how to do this

if($TimeVisit < $CoverTimeStart || $TimeVisit > $CoverTimeFinish || $TodayDay < 01 || $TodayDay > 05)
{
echo "<script Language=Javascript> var Message = 'This job is a chargable visit because the customer does not have maintenance cover. If you wish to continue click ok.'
if (! confirm (Message))
{
location.href='../Calendar.php'
}

what i need to find out is how i can see if the ok button is pressed in this java script bit so i can carry out the correct code (which is of course php)

</script>";
}
else
{
the code here if the if statment is not met

regards
Pred
[a href="http://www.sloganizer.net/en/" target="_blank"][/a]

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 19 April 2006 - 01:49 PM


Use a function like the one below, which can be activated onClick.
Have it redirect you to a php url with ?buttonClicked=true on the URL or something like that. ??

Do you really need to use a javascript alert box? would a splash/holding page with the agree/disagree option not do the trick?



<script type="text/javascript">
<!--
function relocate()
{
window.location = "http://www.yourdomain.com/yourpage.php?action=whatever"
}
//-->
</script>

<a href="#" onClick="relocate();">Whatever, I agree without reading stuff anyway.</a>

wisewood: proven fact, I am both wise, and wooden.

#3 predator12341

predator12341
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts
  • LocationCheshunt, Hertfordshire, England

Posted 19 April 2006 - 01:52 PM

yea but that will not act as me pop up box will it. as what i have is if cancel is clicked it goes back to a different page. however, if ok is clicked and they wat to go ahead with the booking i need it to use this php script (which uses variables declared earlier on so i really want to keep it all in this one page if it is possible)

PS hey again wise wood have a nice weekend. I did lol i got p*ssed out me face a nice way to end the week



echo "<script Language=Javascript> var Message = 'This job is a chargable visit because the customer does not have maintenance cover. If you wish to continue click ok.'
if (! confirm (Message))
{
location.href='../Calendar.php'
}
else
{
from what i can work out i need a way of putting the php in here

}
</script>";
[a href="http://www.sloganizer.net/en/" target="_blank"][/a]

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 19 April 2006 - 02:10 PM

<script Language=Javascript> 
<!--
function predator12341()
{
var location= confirm("This job is a chargable visit because the customer does not have maintenance cover. If you wish to continue click ok.");
if (location== true)
 {
   window.location="yourpage.php?clicked=YES";
 }
else
 {
  window.location="yourpage.php?clicked=NO";
  }
}
//-->
</script>

<a href="#" onClick="predator12341();">Whatever, I agree without reading stuff anyway.</a>

Yeah pretty good weekend... painted the living room ceiling and FINALLY got round to upgrading the pc to XP.

PS. ^^^ That should do it.
wisewood: proven fact, I am both wise, and wooden.

#5 predator12341

predator12341
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts
  • LocationCheshunt, Hertfordshire, England

Posted 19 April 2006 - 02:16 PM

[!--quoteo(post=366427:date=Apr 19 2006, 03:10 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 19 2006, 03:10 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<script Language=Javascript> 
<!--
function predator12341()
{
var location= confirm("This job is a chargable visit because the customer does not have maintenance cover. If you wish to continue click ok.");
if (location== true)
 {
   window.location="yourpage.php?clicked=YES";
 }
else
 {
  window.location="yourpage.php?clicked=NO";
  }
}
//-->
</script>

<a href="#" onClick="predator12341();">Whatever, I agree without reading stuff anyway.</a>

Yeah pretty good weekend... painted the living room ceiling and FINALLY got round to upgrading the pc to XP.

PS. ^^^ That should do it.
[/quote]

with the above the var's i currently have on the page will not be passed on (and i dont wanna pass them on through the url or anything is there any way around this or can i do what i am trying to another way in php)

[a href="http://www.sloganizer.net/en/" target="_blank"][/a]

#6 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 19 April 2006 - 02:30 PM

Send me a PM with the details of what you're trying to do and i'll see if i can figure out a way of doing it.
Give me an idea what you want the user to be presented with after they say "Yes" on the form, and i'll see what i can come up with.

wisewood: proven fact, I am both wise, and wooden.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users