Jump to content
Larry Ullman's Book Forums

Ron

Members
  • Posts

    3
  • Joined

  • Last visited

Ron's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Domo HartleySan! First off, I would like to recognize your willingness to share your knowledge in a way that assists others in growing their knowledge as well. My first inclination was to separate the script from HTML as you suggested, but was unclear on how to accomplish this. I believe that your example got me moving in the right direction. Here are some observations that I made during testing: 1. Both of the following anonymous function calls accomplish the same thing in IE8 without JS errors: document.getElementById('seasonid').onchange = function() {window.location.href="reports.php?season=" + this.value}; document.getElementById('seasonid').onchange = function() {window.location.href="reports.php?season=" + this.form.seasonid.options[this.form.seasonid.selectedIndex].value}; I speculate that 'this' conditionally references different objects based on how the object is being qualified (at least in IE8). 2. While the 'seasonid' element may be referenced as document.getElementById('seasonid') in IE8, Firefox 4 returns a 'null' value for this reference. However, your second solution 'document.forms[0].seasonid' works well in both browsers. 3. If I attempt to create a second select element named 'purch' and append its value in the query string '&purch=purch.value' works without error in IE8, but 'purch' is not recognized as an object in Firefox 4. So I'm already running into browser incompatabilities, and I haven't even tested in Safari or Opera yet! This brings us to your final point. My ultimate strategy is to add an AJAX layer to the application. However, the reading that I have done so far suggests that it is preferable to have a working solution that functions without AJAX so that users whose browsers are incompatible with the required technology can still use the application. Then and only then should AJAX technology be added. For me, this begs the question: will my compatibility issues be compounded by adding an AJAX layer? I do understand the issue your raise regarding the current strategy, and the need to reload the page every time the select option is changed. However, I don't anticipate that users will be using this functionality regularly. I simply wanted to make it available in the off chance that users wanted to review previous seasons' data. Thank you again for taking the time to share your thoughts and to guide me. I look forward to your thoughts on the above.
  2. Thank you for your reply Larry. You are corret, I did misplace the single open quote. Unfortunately, when I attempt to wrap the entire redirect target in single quotes, the bit of code meant to determine the chosen option is sent as a literal string, so I get a URL of: "http://www.redfalconmarketing.com/SDFSCScrip/reports.php?season=this.form.seasonid.options[this.form.seasonid.selectedIndex].value" I've tried every workaround that is obvious to me, including creating a JavaScript function to build the redirect on the fly, but so far no joy. What I am attempting to do here is refresh a report patameters page based on a sporting season.
  3. Although this issue is not PHP specific, I am using PHP to generate a form in HTML. My script generates the following page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml: lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>SDFSC Scrip</title> <style type="text/css" media="all">@import "includes/style.css";</style> </head> <body> <div id="wrapper"> <div id="banner"> <span><img id='logo_z1' src='images/TdS.png' /></span> <span id='logo_z2'>Team del S l </span> <span id='head'>Scrip Program</span> <span id='greeting'>Hi Anderson Family!</span> <span id='logout'><a href='login.php?logout=true'>logout</a></span> </div> <!-- end banner --> <div id='menu'> <span id='selnav'> Reports </span> <span id='nav'><a href='help.php'> Help </a></span> <form method='post' action='reporthandler.php'> <span id='season'><label>Season: </label> <select name='seasonid' onchange="window.location.href=reports.php?season=this.form.seasonid.options[this.form.seasonid.selectedIndex].value"> <option value=2>2011-2012</option> <option value=1>2010-2011</option> </select></span></div> <!-- end menu --> <div id='main'> </form> <!-- end form --> </div> <!-- end main --> </div> <!-- end wrapper --> </body> </html> On line 22, the expected behavior of the SELECT is: When the option is changed by the user, the page will redirect to itself, with a query string identifying the options selected. The actual behavior is: nothing happens If I hardcode the onchange method with: <select name='seasonid' onchange="window.location.'href=reports.php?season=1'"> then then page redirects I have researced many forums and tutorials, and cannot find an suitable answer. Has anyone solved a similar problem? Thank you.
×
×
  • Create New...