Re: Notification of listbox selection change

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 9, 2014 at 11:54 AM, Tedd Sperling <tedd@xxxxxxxxxxxx> wrote:
> Larry:
>
> You are making this more complicated than it needs to be.
>
> I simply have an index page that contains a div to hold the three selection controls (state/cit/zip).
>
> I use another php script (get.php) to present/populate the selection controls AND gather the data needed.
>
> The selection controls trigger the ajax routine like so:
>
> <select name="state" onchange="javascript:get(this.parentNode);">
>
> The ajax routine sends the value selected to the get.php script which in-turn repopulates the selection controls.
>
> Repeat and rinse.
>
> tedd
>
> PS: Why use framesets?

Like I said, I totally understand how your code works. This is not a
new app I am developing from scratch. It's a big existing app that was
written a long time ago. Currently when the user makes selections they
have to click on a submit button. I was asked to make it so that their
selections take effect immediately and to get rid of the submit
button. The easiest thing for me to do was to call the same php code
that get called when the submit button is clicked. I have it working,
I just need to find a workaround for IE. Apparently innerHTML is
read-only in IE. I've read that using jQuery gets around this. But
jQuery is not installed on my client's sites.

> On Jan 9, 2014, at 1:40 PM, Larry Martell <larry.martell@xxxxxxxxx> wrote:
>
>> On Thu, Jan 9, 2014 at 11:15 AM, Tedd Sperling <tedd@xxxxxxxxxxxx> wrote:
>>> Larry:
>>>
>>> You don't replace the entire page -- you fill-in the portion needed.
>>>
>>> What you are missing here is DOM scripting.
>>>
>>> The Ajax portion sends a GET request to a php script (get.php) that does all the db heavy work which in turn repopulates a "myspan" div, like so:
>>>
>>> (index.php)
>>>
>>> <div id="myspan">       <!-- start of myspan -->
>>>        <?php include("get.php"); ?>
>>> </div>                  <!-- end of myspan -->
>>>
>>> The get.php script has all the database stuff including the $_GET[] that brings in the state, city, and zip values.
>>>
>>> Based upon what is provided, get.php script pulls the data from the db and populates the select controls with what is needed.
>>>
>>> There is no refresh of the index page, but rather just an update of the "myspan" div via get.php.
>>
>> Tedd-
>>
>> I understand how your code works. My application is slightly
>> different. My page looks like this:
>>
>> <html>
>>   <head>
>>      <title>Main </title>
>>   </head>
>>   <frameset frameborder=1 border=1 rows="140,*">
>>      <frame src="mainheader.php>
>>      <frameset frameborder=1 border=1 cols='75%,25%'>
>>         <frame src="main.php" name="main">
>>         <frame src="selection.php" name="selection">
>>      </frameset>
>>   </frameset>
>> </html>
>>
>> From within the selection frame I call your makeRequest function with
>> mainframes.php. I get back a complete new page. I got this to work by
>> doing this:
>>
>> top.document.childNodes[0].innerHTML = response;
>>
>> This works on FF, Chrome, and Safari, but on IE it fails with:
>>
>> SCRIPT600: Could not set the innerHTML property. Invalid target
>> element for this operation. Still googling for a solution for that.
>>
>>
>>> On Jan 8, 2014, at 5:17 PM, Larry Martell <larry.martell@xxxxxxxxx> wrote:
>>>
>>>> On Sat, Dec 14, 2013 at 7:00 AM, Tedd Sperling <tedd@xxxxxxxxxxxx> wrote:
>>>>> On Dec 9, 2013, at 3:40 PM, Larry Martell <larry.martell@xxxxxxxxx> wrote:
>>>>>
>>>>>> Is there any way in php to have a function be called when the value of
>>>>>> a listbox selection changes?
>>>>>
>>>>> Larry:
>>>>>
>>>>> Sure, take a look at this:
>>>>>
>>>>> http://php1.net/a/zipcode-states/
>>>>>
>>>>> Everything except the database is there -- you as you may.
>>>>
>>>> Tedd-
>>>>
>>>> Thanks very much for this. I just got around to trying it, and I
>>>> adapted it for my needs and it's basically working. The one issue I
>>>> have is that my request returns a complete new page and I want to
>>>> replace the existing page with that. The problem is that the request
>>>> originates from a frame and when I try and replace the page with the
>>>> response the new page get rendered within the frame. Do you know how
>>>> to replace the entire page with the response?
>>>>
>>>> I've tried:
>>>>
>>>> document.open();
>>>> document.write(response);
>>>> document.close();
>>>>
>>>> and:
>>>>
>>>> var newDoc = document.open("text/html", "replace");
>>>> newDoc.write(response);
>>>> newDoc.close();
>>>>
>>>> But I got the same undesirable results from both.
>>>>
>>>> I realized this is not really a PHP question, but I wanted to continue
>>>> this thread here as others could benefit from it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux