GET Variables and Jumpy Pages

Discussion in 'Web Design and Development' started by citizenzen, Mar 25, 2010.

  1. citizenzen macrumors 65816

    Joined:
    Mar 22, 2010
    #1
    I'm a graphic designer who dabbles in web development (noob). I am creating an HTML form that includes PHP and Javascript. I have a pull-down menu that passes a variable to the url so I can dynamically insert content based upon the pull-down choice.

    My problem: the pull-down is located far enough down the page so that when a selection is made the page jumps up to the top. I can add a #foo to the URL to prevent the page jump, but then the variable no longer is recognized by my PHP. Alternatively, I can remove the #foo from the URL and gets a variable that passes, but a jumpy page.

    Here's my code...

    print "<select name=\"paperTypeSelect\" onchange=\"window.open(this.options[this.selectedIndex].value,'_top')\">";
    switch ($paperTypeSelect)
    {
    case (isset($_GET["paper"])):
    print "<option value=\"$paperType\" value=\"workRequest.php?function=jobSpecs&paper=$paperType\">$paperType</option>";
    break;
    default:
    print '<option value="">Choose Text or Cover Weight...</option>';
    break;
    }
    print '<option value="workRequest.php?function=jobSpecs&paper=text">Text</option>';
    print '<option value="workRequest.php?function=jobSpecs&paper=cover">Cover</option>';
    print '<option value="workRequest.php?function=jobSpecs&paper=ncr">NCR</option>';
    print '</select>';
    print '<br />';
    switch ($paperType) {
    case ($paperType == 'text'):
    print 'x';
    break;
    case ($paperType == 'cover'):
    print 'y';
    break;
    case ($paperType == 'ncr'):
    print 'z';
    break;
    default:
    print '';
    break;

     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Look into AJAX, it would be your best bet, that way the page will not to reload. Using a JavaScript library will be the easiest way to make use of AJAX from your standpoint. jQuery would be a recommendation for that.
     

Share This Page