SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    0 Post(s)
    0 Thread(s)

    <form method="get"...>

    I'm trying to customize a script, particularly a form that uses the "get" method to filter a directory listing. The way it works right now is by pushing the "Submit" button the selected values are appended to the URL so that it looks like:

    Back to the form, field1 is a selection list, so is field2. I want to add checkboxes to the form so that they play the role of a single field but with multiple selections possible. I want it to affect the URL in the following way:,2,4

    Question is, how do I go about building the checkboxes so that upon selecting them and hitting the submit button, the selected values are assigned to the field3 option, delimited by comma. I've been playing with:
    HTML Code:
    <input type="checkbox" name="field3[]" value="1" />
    <input type="checkbox" name="field3[]" value="2" />
    <input type="checkbox" name="field3[]" value="3" />
    <input type="checkbox" name="field3[]" value="4" />
    Right now the output URL looks like[]=1&field3[]=2&field3[]=4 which isn't what I expect it to look like. Please advise or ask for more info if I did not make myself clear, thanks a lot!

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2007
    New London, CT
    0 Post(s)
    0 Thread(s)
    firstly this is more of a php question. But I think you shoul dbe able to accomplish what youare looking for using something similar to the following when you are processing the checkboxes:
    Code PHP:
    	$formFieldName = implode(', ', $_REQUEST['formFieldName']);

    That is how I do it on my forms. Not sure if it is the best way but it gets the jobs done for me.

    Hope that is what you are looking for and helps.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts