Querystring Parsing Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fastly

    Querystring Parsing Problem

    Hi Guys

    I'm no Javascript guru, although am fairly confidant using PHP... What I
    have knocked together here uses PHP to create a querystring without the
    iso=XX value, and dump it's output within some Javascript code.

    The reason for this script is to reload a page with their country settings
    (i.e. state for us but not for uk) on the form. If iso=uk is already in the
    querystring we want to strip this from the querystring and use the
    'iso_val'.

    <script language="JavaS cript" type="text/JavaScript">
    function reloadCountry(f e) {
    var opt_key = fe.selectedInde x;
    var iso_val = fe.options[opt_key].value;
    window.open('?i so=' + iso_val + '<?

    foreach($_GET as $k => $v) {
    if ($k != 'iso') {
    $string .= "&$k=$v";
    }
    }

    echo $string;

    ?>','_top');
    return true;

    }
    </script>

    How do I do this without the PHP?? I'm starting to use template engines such
    as smarty and the PHP code is getting in the way of this.

    I'm sure there is a simple solution, but any advice would be greatly
    appreciated.

    Many Thanks

    Alex

    --
    "Big boast, small roast."
  • Fastly

    #2
    Re: Querystring Parsing Problem

    Hi Guys

    I'm surprised no one has answered to this.. Surely this is something that
    needs to be achieved all the time.. i.e. when you want to keep the rest of
    the page intact and select another option from a dynamic dropdown list
    etc.. I've just discovered two more sections of my site where this would
    come in useful.

    I need to scroll through each item in the querystring... rebuild the
    querystring without certain elements... or replacing certain element with
    the value of the object that triggered the event.

    Any ideas?

    Thanks

    Alex

    Fastly wrote:
    [color=blue]
    > Hi Guys
    >
    > I'm no Javascript guru, although am fairly confidant using PHP... What I
    > have knocked together here uses PHP to create a querystring without the
    > iso=XX value, and dump it's output within some Javascript code.
    >
    > The reason for this script is to reload a page with their country settings
    > (i.e. state for us but not for uk) on the form. If iso=uk is already in
    > the querystring we want to strip this from the querystring and use the
    > 'iso_val'.
    >
    > <script language="JavaS cript" type="text/JavaScript">
    > function reloadCountry(f e) {
    > var opt_key = fe.selectedInde x;
    > var iso_val = fe.options[opt_key].value;
    > window.open('?i so=' + iso_val + '<?
    >
    > foreach($_GET as $k => $v) {
    > if ($k != 'iso') {
    > $string .= "&$k=$v";
    > }
    > }
    >
    > echo $string;
    >
    > ?>','_top');
    > return true;
    >
    > }
    > </script>
    >
    > How do I do this without the PHP?? I'm starting to use template engines
    > such as smarty and the PHP code is getting in the way of this.
    >
    > I'm sure there is a simple solution, but any advice would be greatly
    > appreciated.
    >
    > Many Thanks
    >
    > Alex
    >[/color]

    --
    "Big boast, small roast."

    Comment

    Working...