Reputation: 13005
I'm having a radio button group of three radio buttons with same name but different ids as follows:
<p class="custom-form">
<input type="radio" name="generate_paper" id="generate_paper_manual" value="manual" checked="checked" onChange="change_paper_generate_type();" /> <label for="generate_paper_manual">Manual</label>
<input type="radio" name="generate_paper" id="generate_paper_auto" value="auto" onChange="change_paper_generate_type();" /> <label for="generate_paper_auto">Auto Generate</label>
<input type="radio" name="generate_paper" id="generate_own_paper" value="own"/> <label for="generate_paper_own">Own Paper</label>
</p>
Now I want to show a confirmation popup message "Do you want to generate own test questions ?" and Yes/No button. If user clicks on Yes button then the page should be redirected to URL "/eprime/entprm/web/control/modules/users/view_users.php". If user clicks on No the opened popup should get close. Can anyone help me in this regard? Thanks in advance.
Upvotes: 0
Views: 1663
Reputation: 1186
Use Confirm as dialog box. If it return true redirect to wanted page.
if(confirm("YOUR QUESTION?"))
{
document.location.href="URL OF PAGE";
}
Upvotes: 1
Reputation: 7108
You can use Javascript popup boxes (window.confirm) or, if you prefer, jquery dialogs or other DOM-based dialogues.
To change url you can set window.location.href:
window.location.href = "/eprime/entprm/web/control/modules/users/view_users.php";
Upvotes: 0
Reputation: 1652
UPDATED, try:
if (confirm("Do you want to generate own test questions ?"))
document.location.href = "/eprime/entprm/web/control/modules/users/view_users.php";
I'm wrong with function name
Upvotes: 1
Reputation: 128836
Use window.confirm()
:
result = window.confirm(message);
message
is the optional string to be displayed in the dialog.result
is a boolean value indicating whether OK or Cancel was selected (true means OK).
if (window.confirm("Do you want to generate own test questions ?"))
window.location.href = "/eprime/entprm/web/control/modules/users/view_users.php";
Upvotes: 1