Page 1 of 1

client side to back end - or what to do with back button?

Posted: Tue Jan 24, 2006 10:15 pm
by tim_kinder
Hello,

I have to link my client-side (javascript) with back-end (php, MySQL). Let say, when I choose a new value in pull-down list, I want the back end to display something based on this new value.

So I have pull-down list with onchange() :


<select onchange="update_display(this);" ...>
...
</select>


I also have a frame for updating script :

<iframe name="update_frame" ... src="update.php">...</iframe>


And JavaScript

function update_display( me )
{
var url = 'update.php?'+me.value;
var f = self.frames['update_frame'];
f.location = url;
return true;
}


Everything works - but when I click back button in IE - it rolls back update.php in the frame first instead of rolling back the main page.

I do understand frames are not the best solution, but may be there is a work around?

Sincerely,

Tim Kinder

Posted: Tue Jan 24, 2006 10:32 pm
by neophyte
I'm not sure I'm following you exactly. If you're trying to build a dynamic select menu that changes url's when you make a selection the basic process might be something like....

1. Pull options from db
2. Build dynamic links
3. Echo selection menu -- html
4. Put JS in place to handle onChange events.
5. Build page to show dynamic content

Posted: Tue Jan 24, 2006 11:09 pm
by josh
I make it so the form submits itself to update the dropdowns, this mimics an ajax style application, with the downside of the whole page reloading, with the up-side of working just as well in non-js browsers. You just put a button that says "Next" next to the dropdown inside a noscript tag, and you have the onchange on the dropdown submit the form so it works like this:


User with JS changes the dropdown, the form submits and the page senses the form is half filled out, it populates the next dropdown based on previously filled out values. All the dropdowns below it are grayed out.

User without JS get's the same exact experience with the minor inconvenience of having to click the next button each time.

Posted: Tue Jan 24, 2006 11:09 pm
by tim_kinder
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


[quote="neophyte"]I'm not sure I'm following you exactly.[/quote]


here is an example - http://onworldweb.com/frames/frames.html

p1.php is like this :

Code: Select all

<?php
echo " this should come from back-end<br/>\n";
	foreach ( $_REQUEST as $i => $r )
	{
		echo "[{$i}] => ";
		print_r( $r );
		echo "<br/>\n";
	}
		
?>
after I change pull down list, I want the back-end (p1.php) to do something and update some part of the screen.

the problem is it all comes to history, so when i select red-green-blue-red-green-blue - it moves back to green-red-blue ... - and I want the same behavour as it was updated from client-side, not from back-end (back button moves back to previous screen, if any)


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Wed Jan 25, 2006 7:07 am
by raghavan20
you have to use AJAX or IFRAMES to implement the above