Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript prompt

    Hello

    I am using this

    Code:
    
    <script language="JavaScript">
    
    
      function confirm_prompt(text) {
        if (confirm(text)) {
          
        }
      }  
    </script>
    on <head> section plus this

    Code:
       
    ..
    ..
    <input type="submit" value="   CONTINUE     "  name="continue"  onclick="confirm_prompt('do you agree?'); return false;" value="" >
    ..
    ..
    to show an alert when someone click on CONTINUE BUTTON .

    the problem is ... I have also 2 radio modules

    Code:
    ..
    ..
    <INPUT TYPE="radio" VALUE="no" NAME="transfer" checked>
    <INPUT TYPE="radio" VALUE="yes" NAME="transfer">
    ..
    ..
    ..and I wish to show the alert above ONLY if transfer (radio) value is yes and checked. Is it possible ? How to modify my script above to do that ?


    Thank you
    Graziano

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Use onsubmit, not onclick as validator event handler.
    Try this:
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script language="JavaScript" type="text/JavaScript">
    function 
    confirm_prompt(myform,text) {
        if(
    myform.transfer[1].checked){
            if (!
    confirm(text)) {
              return 
    false
            
    }
        }
      } 
    </script>
    </head>
    <body>
    <form onsubmit="return confirm_prompt(this,'do you agree?')">
    <INPUT TYPE="radio" VALUE="no" NAME="transfer" checked>NO<br>
    <INPUT TYPE="radio" VALUE="yes" NAME="transfer">YES<br>
      <input type="submit" name="continue" value="Continue" >
    </form>
    </body>
    </html> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello Kor ,

    thank you but it doesn't work (nothing happens when I click on continue button) , and as it seems it checks for ".checked" when I need to check if transfer value is "yes".

    p.s. my wife is of Craiova

  • #4
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone can help please ? Thank you

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    It works. When click on continue
    - if No is checked the form is submitted with no confirm
    - if Yes is checked the confirm opens. If OK, the form is submitted, if Cancel, the submit is stoped.

    Isn't it what you wanted?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    strange for me it didn't work . However I solved in this way

    Code:
    <html>
    <head>
    <title>Transfer or Register</title>
    </head>
    
    <body>
    
          <script>
    		<!--
    	
    		function ownercheck(bValue)
    		{
    		var _textForDisplay;
    		
    		_textForDisplay = "You have selected to transfer a domain name." + 
    						"To confirm that you are the legal owner of this domain name " +
    						"please click OK. If you are not the legal owner, " + 
    						"please click Cancel and search for a new domain.";
    		
    		if(bValue)
    		{
    			if(document.formtransfer.domainSearchTransferOption.checked)
    			{	
    				var _answer = window.confirm(_textForDisplay);
    				if(_answer)
    					document.formtransfer.submit();
    				else
    					return;	
    					window.location = 'http://www.notransfer.com';
    			}
    			else
    				{
    				document.formtransfer.submit();
    				}
    		}
    		else
    			document.formtransfer.submit();		
    		}	
    		//-->
    	  </script>
       
    	<form action="http://www.yestransfer.com" ID="formtransfer" name="formtransfer">
    
                <input type="radio" name="transfer" value="true" ID="transfer" checked>
    			 <strong>New Domain Name</strong> <br>
    <input type="radio" name="transfer" value="false" ID="domainSearchTransferOption">
    			<strong>Transfer an Existing Domain Name<br>
                </strong>&nbsp;<input type="submit" value="Invia" name="B1" onclick="JavaScript:ownercheck(true); return false;" >
    	
    
    </form>
    </body>
    </html>

  • #7
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Probably you have not added the action in form, in my example. Your code is somehow the same, but it is more intricate, as you have chosen to return false the submit button action, than submit with a submit() javascript method, while I just called for a return directly in form. In rest, should work the same.

    ----
    If your wife is Romanian... have't you lear some Romanian till now?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #8
    New Coder
    Join Date
    Nov 2004
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ops sorry , I copied an pasted your code but it didn't work because
    I didn't put an action on <form> , sorry !

    We married only on june I am still learning .
    We are leaving in Italy so we speak always italian.
    However I am learning romanian too , it's doesn't seem so hard
    because it comes from latin such as italian .
    One day I will travel to craiova and I will hope to learn it better .

    Thank you again!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •