confirm as in javacript confirm
Posted: Wed Aug 19, 2009 7:48 am
I am a novice writing a web-site and at one point I am faced with offering my users a choice of 'confirm' or 'cancel'.
Confirm takes them straight to homepage and cancel required a function before going to home page.
How to do this worried me until I cam across javascript confirm. BUT it is ugly ! I cannot alter it with css.
I hunted on the internet and found various complex, and beautiful java implementations but I want something simple !
SO this is what I did (in Joomla) is it safe ? and is it reliable? As a novice I have no idea so please help.
I made a simple form with two submit buttons
This form action goes to the home page
The at the top of the home page I put inside a php call
It seems to work if I look at the echos put there for that purpose...but is it reliable ?
Any advice or help welcome.
Or is there a better way to do it ?
--
Dave
Confirm takes them straight to homepage and cancel required a function before going to home page.
How to do this worried me until I cam across javascript confirm. BUT it is ugly ! I cannot alter it with css.
I hunted on the internet and found various complex, and beautiful java implementations but I want something simple !
SO this is what I did (in Joomla) is it safe ? and is it reliable? As a novice I have no idea so please help.
I made a simple form with two submit buttons
Code: Select all
echo "<form id=\"myform\" action = \"index.php?option=com_content&view=article&id=38&Itemid=44\" method = \"post\" target= \"self\" style = \"margin: 0px;\">";
echo "<input type = \"submit\" id=\"butnA\" name = \"butnA\" value = \"A\" >";
echo "<input type = \"submit\" id=\"butnB\" name = \"butnB\" value = \"B\" >";
echo "</form>";
The at the top of the home page I put inside a php call
Code: Select all
$name1 = "butnA";
$name2 = "butnB";
$aresult = JRequest::getVar($name1);
echo "<p>A result is $aresult</p>";
if ($aresult){ functionA();}
else
{
$bresult = JRequest::getVar($name2);
echo "<p> B result is $bresult</p>";
if ($bresult){ functionB();}
else{ //carry on as normal to display the home page
Any advice or help welcome.
Or is there a better way to do it ?
--
Dave