PHP Drop Down Selection

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

    PHP Drop Down Selection

    I was wondering if anyone had any good methods for this problem.

    I have a drop down box that is generated:

    Status: <select name="tt_ticket statusid" class="swiftsel ect"><option
    value="1" style="" selected="selec ted">Open</option>
    <option value="2" style="">On Hold</option>
    <option value="3" style="">Closed </option>
    <option value="5" style="">Awaiti ng Customer Response</option>
    <option value="4" style="">Potent ially Resolved</option>
    <option value="6" style="color: teal;">On Hold - potential future
    release</option>
    <option value="7" style="">Potent ially Resolved, Next Release</option>
    <option value="9" style="">Fixed - Next Release</option>
    <option value="10" style="">Intern al Change</option>
    </select>

    The website I am doing this with is pretty complicated and has AJAX
    and PHP OOP running everywhere.

    I need to have the drop down box automatically select the value 5 - I
    have already located the event where I want this to take place - but I
    am not sure how I would go about making a drop down box select an
    option after it has been written to the page.

    Maybe with Javascript?

  • Philipp Grassl

    #2
    Re: PHP Drop Down Selection

    If you for example want to select the fourth option (here "Awaiting
    Customer Response") you could do it with the JavaScript-line:

    document.getEle mentsByName("tt _ticketstatusid ")[0].selectedIndex= 3;

    SterLo schrieb:
    I was wondering if anyone had any good methods for this problem.
    >
    I have a drop down box that is generated:
    >
    Status: <select name="tt_ticket statusid" class="swiftsel ect"><option
    value="1" style="" selected="selec ted">Open</option>
    <option value="2" style="">On Hold</option>
    <option value="3" style="">Closed </option>
    <option value="5" style="">Awaiti ng Customer Response</option>
    <option value="4" style="">Potent ially Resolved</option>
    <option value="6" style="color: teal;">On Hold - potential future
    release</option>
    <option value="7" style="">Potent ially Resolved, Next Release</option>
    <option value="9" style="">Fixed - Next Release</option>
    <option value="10" style="">Intern al Change</option>
    </select>
    >
    The website I am doing this with is pretty complicated and has AJAX
    and PHP OOP running everywhere.
    >
    I need to have the drop down box automatically select the value 5 - I
    have already located the event where I want this to take place - but I
    am not sure how I would go about making a drop down box select an
    option after it has been written to the page.
    >
    Maybe with Javascript?
    >

    Comment

    • SterLo

      #3
      Re: PHP Drop Down Selection

      Sweet - how do I get it to run automatically after the page has
      loaded?
      I can't create an object in the header and then call it so I need to
      call that line of javascript right after the page is done.
      Any suggestions?

      On May 22, 12:38 pm, Philipp Grassl <p.gra...@gmx.a twrote:
      If you for example want to select the fourth option (here "Awaiting
      Customer Response") you could do it with the JavaScript-line:
      >
      document.getEle mentsByName("tt _ticketstatusid ")[0].selectedIndex= 3;
      >
      SterLo schrieb:
      >
      I was wondering if anyone had any good methods for this problem.
      >
      I have a drop down box that is generated:
      >
      Status: <select name="tt_ticket statusid" class="swiftsel ect"><option
      value="1" style="" selected="selec ted">Open</option>
      <option value="2" style="">On Hold</option>
      <option value="3" style="">Closed </option>
      <option value="5" style="">Awaiti ng Customer Response</option>
      <option value="4" style="">Potent ially Resolved</option>
      <option value="6" style="color: teal;">On Hold - potential future
      release</option>
      <option value="7" style="">Potent ially Resolved, Next Release</option>
      <option value="9" style="">Fixed - Next Release</option>
      <option value="10" style="">Intern al Change</option>
      </select>
      >
      The website I am doing this with is pretty complicated and has AJAX
      and PHP OOP running everywhere.
      >
      I need to have the drop down box automatically select the value 5 - I
      have already located the event where I want this to take place - but I
      am not sure how I would go about making a drop down box select an
      option after it has been written to the page.
      >
      Maybe with Javascript?

      Comment

      • Philipp Grassl

        #4
        Re: PHP Drop Down Selection

        Just put the JavaScript code into the body as the last Tag like for example

        ---
        <html>
        <head>
        [...]
        </head>
        <body>
        [...]
        <script>
        document.getEle mentsByName("tt _ticketstatusid ")[0].selectedIndex= 3;
        </script>
        </body>
        </html>
        ---


        SterLo schrieb:
        Sweet - how do I get it to run automatically after the page has
        loaded?
        I can't create an object in the header and then call it so I need to
        call that line of javascript right after the page is done.
        Any suggestions?
        >
        On May 22, 12:38 pm, Philipp Grassl <p.gra...@gmx.a twrote:
        >If you for example want to select the fourth option (here "Awaiting
        >Customer Response") you could do it with the JavaScript-line:
        >>
        >document.getEl ementsByName("t t_ticketstatusi d")[0].selectedIndex= 3;
        >>
        >SterLo schrieb:
        >>
        >>I was wondering if anyone had any good methods for this problem.
        >>I have a drop down box that is generated:
        >>Status: <select name="tt_ticket statusid" class="swiftsel ect"><option
        >>value="1" style="" selected="selec ted">Open</option>
        >><option value="2" style="">On Hold</option>
        >><option value="3" style="">Closed </option>
        >><option value="5" style="">Awaiti ng Customer Response</option>
        >><option value="4" style="">Potent ially Resolved</option>
        >><option value="6" style="color: teal;">On Hold - potential future
        >>release</option>
        >><option value="7" style="">Potent ially Resolved, Next Release</option>
        >><option value="9" style="">Fixed - Next Release</option>
        >><option value="10" style="">Intern al Change</option>
        >></select>
        >>The website I am doing this with is pretty complicated and has AJAX
        >>and PHP OOP running everywhere.
        >>I need to have the drop down box automatically select the value 5 - I
        >>have already located the event where I want this to take place - but I
        >>am not sure how I would go about making a drop down box select an
        >>option after it has been written to the page.
        >>Maybe with Javascript?
        >
        >

        Comment

        • Brad

          #5
          Re: PHP Drop Down Selection

          On May 22, 3:18 pm, SterLo <sterling.hamil ...@gmail.comwr ote:
          I was wondering if anyone had any good methods for this problem.
          >
          I have a drop down box that is generated:
          >
          Status: <select name="tt_ticket statusid" class="swiftsel ect"><option
          value="1" style="" selected="selec ted">Open</option>
          <option value="2" style="">On Hold</option>
          <option value="3" style="">Closed </option>
          <option value="5" style="">Awaiti ng Customer Response</option>
          <option value="4" style="">Potent ially Resolved</option>
          <option value="6" style="color: teal;">On Hold - potential future
          release</option>
          <option value="7" style="">Potent ially Resolved, Next Release</option>
          <option value="9" style="">Fixed - Next Release</option>
          <option value="10" style="">Intern al Change</option>
          </select>
          >
          The website I am doing this with is pretty complicated and has AJAX
          and PHP OOP running everywhere.
          >
          I need to have the drop down box automatically select the value 5 - I
          have already located the event where I want this to take place - but I
          am not sure how I would go about making a drop down box select an
          option after it has been written to the page.
          >
          Maybe with Javascript?
          Why do this in Javascript? All that is required for the default value
          of 5 to be selected is to add the phrase: selected="selec ted" to the
          <optiontag. You can do this with straight HTML, or if the dropdown
          is created via PHP, add it to the function that creates the dropdown.

          Comment

          • SterLo

            #6
            Re: PHP Drop Down Selection

            On May 24, 5:10 am, Brad <street.b...@gm ail.comwrote:
            On May 22, 3:18 pm, SterLo <sterling.hamil ...@gmail.comwr ote:
            >
            >
            >
            I was wondering if anyone had any good methods for this problem.
            >
            I have a drop down box that is generated:
            >
            Status: <select name="tt_ticket statusid" class="swiftsel ect"><option
            value="1" style="" selected="selec ted">Open</option>
            <option value="2" style="">On Hold</option>
            <option value="3" style="">Closed </option>
            <option value="5" style="">Awaiti ng Customer Response</option>
            <option value="4" style="">Potent ially Resolved</option>
            <option value="6" style="color: teal;">On Hold - potential future
            release</option>
            <option value="7" style="">Potent ially Resolved, Next Release</option>
            <option value="9" style="">Fixed - Next Release</option>
            <option value="10" style="">Intern al Change</option>
            </select>
            >
            The website I am doing this with is pretty complicated and has AJAX
            and PHP OOP running everywhere.
            >
            I need to have the drop down box automatically select the value 5 - I
            have already located the event where I want this to take place - but I
            am not sure how I would go about making a drop down box select an
            option after it has been written to the page.
            >
            Maybe with Javascript?
            >
            Why do this in Javascript? All that is required for the default value
            of 5 to be selected is to add the phrase: selected="selec ted" to the
            <optiontag. You can do this with straight HTML, or if the dropdown
            is created via PHP, add it to the function that creates the dropdown.

            "AJAX and PHP OOP" = Complicated online application.
            This website literally has 243 files - more than half with over 2300
            lines of code.
            It's all dynamically created.

            I want to accomplish a simple task for someone - so rather than
            digging through each file and making sure my changes don't break
            anything - I figured javascript or something would help.

            Comment

            Working...