www.webdeveloper.com
Results 1 to 4 of 4

Thread: document.location.href is not execute without alert popup using java script

  1. #1
    Join Date
    Aug 2012
    Posts
    3

    Unhappy document.location.href is not execute without alert popup using java script

    Hi Expert,

    I have a problem for execute the hyperlink in javascript. When i have alert command in for loop "document.location.href " is execute properly , if i remove the alert command. it will not working.

    Please adivce on the below script, how to over come this issue.

    [CODE]

    <script type="text/javascript">
    function DoTheCheck(form)
    {
    for (i=0; i<document.forms["DetailBlock"].p_dmmy_box.length; i++)
    {
    if (document.forms["DetailBlock"].p_dmmy_box[i].checked==true)
    {
    alert("Checkbox at index "+i+" is checked!")
    var p1=document.forms["DetailBlock"].p1.value;
    var ps=document.forms["DetailBlock"].ps.value;
    var p_stt=document.forms["DetailBlock"].p_dmmy_box[i].value;
    var p_cpyno=document.forms["DetailBlock"].p_sttno[i].value;
    var p_wccode=document.forms["DetailBlock"].p_wrtng_co[i].value;
    document.location.href ="https://dev.xxx.com/x/test.load?p_key=Detail&p1="+p1+"&ps="+ps+"&pa1="+p_stt+"&pa2="+p_cpyno+"&pa3="+p_wccod
    }
    }
    </script>

    [ICODE]

    Note: test.load is a stored procedure, which insert date in to temp table. And this should be execute in background only(Could not redirect from current page)

    Thanks
    Hb venki

  2. #2
    Join Date
    Jan 2005
    Posts
    357
    I think we need a little more detail on what happens - do the variable have the wrong values or what?

    (Make sure that you put a semi-colon after that alert line...)

  3. #3
    Join Date
    Aug 2012
    Posts
    3
    Hi, Above script is working fine, if i have the alert command in that for loop. Suppose i comment the alert command in that script it will not make any impact in that hyperlink.

  4. #4
    Join Date
    Aug 2012
    Posts
    3
    For more understanding, i have copied part of the script...

    Code:
    <HTML>
    <HEAD>
    <script type="text/javascript">
    function DoTheCheck(form)
    {
    for (i=0; i<document.forms["DetailBlock"].p_dmmy_box.length; i++)
    {
    if (document.forms["DetailBlock"].p_dmmy_box[i].checked==true)
    {
    alert("Checkbox at index "+i+" is checked!")
    var p1=document.forms["DetailBlock"].p1.value;
    var ps=document.forms["DetailBlock"].ps.value;
    document.location.href ="https://dev.xxx.com/x/test.load?p1="+p1+"&ps="+ps
    }
    }
    </script>
    </HEAD>
    <BODY MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" TOPMARGIN="0" bgcolor="#ffffff"  link="#993300" vlink="#666666" alink="#FFCC00">
    <FORM ACTION="" METHOD="" name="DetailBlock">
    <INPUT TYPE="hidden" NAME="p1" VALUE="78642">
    <INPUT TYPE="hidden" NAME="ps" VALUE="61160224">
     
    <INPUT TYPE="checkbox" NAME="p_dmmy_box" VALUE="123"  onClick="click_checkbox(this.checked,0)">
    </FORM>
    <FORM ACTION="/dbprop/nextpage.sbmt" METHOD="POST" onsubmit="return validate();">
    <INPUT TYPE="submit" VALUE=" Submit " TITLE="Submit" class="button" onmouseover="this.className='hoverbutton'" onmouseout="this.className='button'" onclick=DoTheCheck(this.form)>
    </FORM>
    
    </BODY>
    </HTML>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles