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 7 of 7
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cross(browser)town Traffic

    Hi,

    I've patched together some JS that works fine with IE, but is getting stuck with Mozilla/Netscape. Any assistance with this would be huge:

    <script>
    function opens_BW_on(O_T){
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"";
    }

    function opens_resinc_on(O_T,P_T){
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"&PROP_TYPE="+P_T+"";
    }

    function opens_oday_on(O_T,P_T,openday){
    var P_S_T
    P_S_T = "";
    for (var i = 0; i < form1.PROP_SUB_T.length; i++)
    if (form1.PROP_SUB_T[i].checked)
    P_S_T += form1.PROP_SUB_T[i].value + ",";
    if (P_S_T != ""){
    P_S_T = P_S_T.substring(0,P_S_T.length - 1);
    }
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"&PROP_TYPE="+P_T+"&PROP_SUB_T="+P_S_T+"&o penday="+openday+"";
    }
    </script>

    <html>
    <table>
    <form action="searchresults.asp" method="post">
    <tr>
    <td>Open Type*:</td>
    <td>
    <input type="radio" name="OPEN_TYPE" value="W" onClick="opens_BW_on('W');">Weekend
    <input type="radio" name="OPEN_TYPE" value="B" onClick="opens_BW_on('B');">Brokers</td>
    </tr>
    <tr>
    <td>Property Type*:</td>
    <td>
    <input type="RADIO" name="PROP_TYPE" value="RES" onClick="opens_resinc_on('<%= OPEN_TYPE %>','RES');">Residential<br>
    <input type="RADIO" name="PROP_TYPE" value="INC" onClick="opens_resinc_on('<%= OPEN_TYPE %>','INC');">Multi-Residential Income</td>
    </tr>
    <% If PROP_TYPE = "RES" Then %>
    <tr>
    <td>&nbsp;</td>
    <td>
    <input type="checkbox" name="PROP_SUB_T" value="SFR">SFR&nbsp;
    <input type="checkbox" name="PROP_SUB_T" value="PUD">PUD&nbsp;
    <input type="checkbox" name="PROP_SUB_T" value="CND">COND</td>
    </tr>
    <% End If %>
    <tr>
    <td>Open Day*:</td>
    <td>This Week<br>
    <input type="RADIO" name="openday" value="Monday" onclick="opens_oday_on('<%= OPEN_TYPE %>','<%= PROP_TYPE %>','MONDAY');">MONDAY
    <input type="RADIO" name="openday" value="Monday" onclick="opens_oday_on('<%= OPEN_TYPE %>','<%= PROP_TYPE %>','TUESDAY');">TUESDAY
    etc.. through FRIDAY...

    </html>

    Thank you.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're missing the <head>,<title>,</title> and </head> tags as well as the <body> and </body> tags and your <script> </script> block preceeds the <html> tag when it should be inside the <head </head> or the <body> </body> tags.

    Your <form> tag is illegally placed inside a <table> tag and while you may have not included them for brevity I find no indication that you properly closed the table with </table> or the form with </form>.

    I suggest you review the basics for html since it's apparent you've missed some of those rules and it's breaking those basic rules which is often the source of these kinds of problems.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Roy Sinclair
    your <script> </script> block preceeds the <html> tag when it should be inside the <head </head> or the <body> </body> tags.
    do you know wot's scary, roy, i work on an award winning international piece of service management web-enabled software, and it breaks all the rules going, simply because some guy had a brainwave to get Powerbuilder developers with no web experience to develop a fully J2EE compliant application in under 6 months. of course, i turn up with 1 month to go and am left to tidy up all the crappy and poor structured HTML 3.2 going. you just couldn't make it up

    ps: i forgot to say, we've got upteem script blocks all preceeding the head block. but, hey we've got no doctype declaration, so wot da hell ....
    *keep it simple (TM)

  • #4
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I must admit that WAS one of the sloppier posts I've committed in the name of brevity, and hopefully I haven't turned anyone off by it. I've always tried paring down to the basics when posting here, so let me try it again. Once again, this works in IE but not in Moz/Netscape:

    <% @ Language=VBScript %>
    <%
    PROP_TYPE = "RES"
    If Request.QueryString("PROP_TYPE") <> "" Then
    PROP_TYPE = Request.QueryString("PROP_TYPE")
    End If

    PROP_SUB_T = "SFR"
    If Request.QueryString("PROP_SUB_T") <> "" Then
    PROP_SUB_T = Request.QueryString("PROP_SUB_T")
    End If

    OPEN_TYPE = "B"
    If Request.QueryString("OPEN_TYPE") <> "" Then
    OPEN_TYPE = Request.QueryString("OPEN_TYPE")
    End If

    openday = UCase(WEEKDAYNAME(theDay))
    If Request.QueryString("openday") <> "" Then
    openday = Request.QueryString("openday")
    End If

    %>

    <html>
    <head>
    <title>search page</title>
    <script language="javascript">
    function opens_BW_on(O_T){
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"";
    }

    function opens_resinc_on(O_T,P_T){
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"&PROP_TYPE="+P_T+"";
    }

    function opens_oday_on(O_T,P_T,openday){
    var P_S_T
    P_S_T = "";
    for (var i = 0; i < form1.PROP_SUB_T.length; i++)
    if (form1.PROP_SUB_T[i].checked)
    P_S_T += form1.PROP_SUB_T[i].value + ",";
    if (P_S_T != ""){
    P_S_T = P_S_T.substring(0,P_S_T.length - 1);
    }
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"&PROP_TYPE="+P_T+"&PROP_SUB_T="+P_S_T+"&o penday="+openday+"";
    }
    </script>
    </head>
    <body>
    <form action="searchresults.asp" method="post">
    <table>
    <tr>
    <td>Open Type*:</td>
    <td>
    <input type="radio" name="OPEN_TYPE" value="W" onClick="opens_BW_on('W');">Weekend
    <input type="radio" name="OPEN_TYPE" value="B" onClick="opens_BW_on('B');">Brokers</td>
    </tr>
    <tr>
    <td>Property Type*:</td>
    <td>
    <input type="RADIO" name="PROP_TYPE" value="RES" onClick="opens_resinc_on('<%= OPEN_TYPE %>','RES');">Residential<br>
    <input type="RADIO" name="PROP_TYPE" value="INC" onClick="opens_resinc_on('<%= OPEN_TYPE %>','INC');">Multi-Residential Income</td>
    </tr>
    <% If PROP_TYPE = "RES" Then %>
    <tr>
    <td>&nbsp;</td>
    <td>
    <input type="checkbox" name="PROP_SUB_T" value="SFR">SFR&nbsp;
    <input type="checkbox" name="PROP_SUB_T" value="PUD">PUD&nbsp;
    <input type="checkbox" name="PROP_SUB_T" value="CND">COND</td>
    </tr>
    <% End If %>
    <tr>
    <td>Open Day*:</td>
    <td>This Week<br>
    <input type="RADIO" name="openday" value="Monday" onclick="opens_oday_on('<%= OPEN_TYPE %>','<%= PROP_TYPE %>','MONDAY');">MONDAY
    <input type="RADIO" name="openday" value="Monday" onclick="opens_oday_on('<%= OPEN_TYPE %>','<%= PROP_TYPE %>','TUESDAY');">TUESDAY
    etc.. through FRIDAY...
    </table>
    </form>

    </body>
    </html>

  • #5
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I needed to be more specific with this.

    The first two scripts,

    function opens_BW_on(), and
    function opens_resinc_on()

    are executing fine in each browser.

    What's not working is the 'onclick="opens_oday_on()"' handler used with Mozilla/Netscape.

    In IE 6.0, the window.location changes as it should, but in the others.... nothing.

    Also, I've changed that function from what I had before. It now reads:

    <script language="javascript">

    // other two here...

    function opens_oday_on(O_T,P_T,openday){
    var P_S_T
    P_S_T = "";
    if (form1.PROP_SUB_T && (form1.PROP_SUB_T[0].checked || form1.PROP_SUB_T[1].checked || form1.PROP_SUB_T[2].checked)){
    for (var i = 0; i < form1.PROP_SUB_T.length; i++)
    if (form1.PROP_SUB_T[i].checked)
    P_S_T += form1.PROP_SUB_T[i].value + ",";
    P_S_T = P_S_T.substring(0,P_S_T.length - 1);
    }
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"&PROP_TYPE="+P_T+"&PROP_SUB_T="+P_S_T+"&o penday="+openday+"";
    }
    </script>

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not turned off (but am gone most weekends and some weekdays when busy at work). Just wanted to be sure that it wasn't some sort of simple "the html code is badly messed up" type of problem before I took a deeper look.

    Code:
    function opens_oday_on(O_T,P_T,openday){
    var P_S_T
    P_S_T = "";
    if (document.form1.PROP_SUB_T && (document.form1.PROP_SUB_T[0].checked || document.form1.PROP_SUB_T[1].checked || document.form1.PROP_SUB_T[2].checked)){
    for (var i = 0; i < document.form1.PROP_SUB_T.length; i++)
    if (document.form1.PROP_SUB_T[i].checked)
    P_S_T += document.form1.PROP_SUB_T[i].value + ",";
    P_S_T = P_S_T.substring(0,P_S_T.length - 1);
    }
    window.location.href="searchopenhomes.asp?OPEN_TYPE="+O_T+"&PROP_TYPE="+P_T+"&PROP_SUB_T="+P_S_T+"&openday="+openday+"";
    }
    This should work better. I think the problem you were seeing is related to the fact that IE provides a shortcut reference to the form object that's not available in other browsers. IIRC, all you need to do is add the "document." part to the reference and you're safe for all browsers.

    Turn on the Javascript console in FireFox or Mozilla when debugging javascript and you'll get some information that'' help you find problems easily when a script doesn't work and won't have to waste extra hours on one of us to reply.
    Last edited by Roy Sinclair; 11-01-2004 at 08:15 PM.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #7
    New Coder
    Join Date
    Oct 2002
    Location
    Oakland, CA
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, Roy.

    I stumbled upon that fix yesterday and that WAS in fact the problem. Now I'm looking into using the Javascript Console in Mozilla...

    Thanks 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
    •