Jump to content

fractal5

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fractal5's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is the link to the javascript function, can't edit my OP: http://www.joostdevalk.nl/code/sortable-table/
  2. So I'm trying to use a php form to query results from an sql database and generate a sortable table. For the table sorting I am using a javascript from here: The problem is that the javascript isn't working on the table generated from the php. But if I copy the output of the php into an html, the javascript sort works perfectly. This is a basic sample code I made to test the function: <?php echo "<html><head><title>new page</title>"; echo '<script src="sortable.js"> </script></head>'; echo '<body>'; echo "<table border='0' id='table' class='sortable'>"; echo "<thead>"; echo "<tr>"; echo "<th>Col1</th>"; echo "<th>Col2</th>"; echo "</tr></thead>"; echo "<tbody>"; echo "<tr>"; echo "<td>11</td>"; echo "<td>12</td>"; echo "</tr>"; echo "<tr>"; echo "<td>21</td>"; echo "<td>22</td>"; echo "</tr>"; echo "</tbody></table>"; echo "</body></html>"; ?> So I'm confused as to whether I'm doing something wrong or missing something, or if there's a reason why a javascript function won't work through php. I hope I have explained it clearly. Any help is appreciated.
  3. Can I say I love you? Haha thanks that worked perfectly. I feel dumb for not having thought of that, seems so simple.
  4. Don't mean to interrupt the IE6 convo but I have a new question. Similar enough so I didn't wanna make a new thread for it. I've been able to successfully submit the values to php and have it parse them depending on the button pressed. Now I'm stuck with quite the opposite. I have 2 forms and I need values from both to go to the same php. The first form is already doing it, but I also need to collect the values from the second one and send it to the php being used by the first. Basically both forms contain checkboxes and I need the php to know which checkboxes have been selected from each form. The reason I cannot put the checkboxes in the same form is because I need 1 set of boxes to be on the sidebar, and the second to be on the main frame. Naming the forms the same doesn't work. I even wrote a javascript function which will check which boxes are ticked in the second form and create an identity string accordingly and pass it to the first form, but I can't seem to make this work. I don't think I can pass a javascript string to the body of an html? Any workaround to this? So that I can get values from 2 different forms and submit it to the same php?
  5. I need to have all of it on one page though, makes it more user-friendly. I'm gonna try GG's suggestion and see if I can get it done. Thanks for your help though.
  6. Thanks a ton GuiltyGear. I love that idea of putting them in one form and using the php to see which button was pressed. Also makes the code simpler on several other fronts. As for the teynon's Javascript solution, I don't exactly understand what it is doing. However I was using javascript in the beginning and then chose to move things over to php on suggestions that it can be more secure that way. Well this is kind of just the first draft for the webpage so I'm going to overlook the possibility of the user pressing Enter. Although that did not cross my mind and is something I will consider in the future. By two seperate pages, do you mean different phps?
  7. Is there a way where I can have one form submit to multiple phps depending on which button is clicked? For example if I have: <FORM action="http://localhost/smatrix/phptest/phpcode1.php" name=optionsform METHOD="POST"> <input type="checkbox" name="criteria[]" value="box1"> <input type="checkbox" name="criteria[]" value="box2"> <INPUT TYPE=SUBMIT VALUE="php1" > <INPUT TYPE=SUBMIT VALUE="php2" > </form> Now the other php would be "http://localhost/smatrix/phptest/phpcode2.php" and that is accessed if button "php2" is clicked. Is there any way to do this without using 2 seperate forms? If statements?
  8. As you pointed out the name is changed (so that the php understands) and I realize. I'm wondering if there's a way that I can the javascript check the boxes while keeping the name as "criteria[]". So something like what you suggested, but unfortunately that doesn't work. Or if I can keep the name as "criteria" but am able to post the values to the php. I'm sorry if I'm not very clear but I kinda new to this stuff myself.
  9. Firstly, hi, my first post in these forums. Onto to my problem. I have a set of checkboxes and a button that selects them all. I am able to do this via Javascript. Javascript: function SelectAll2() { boxnum = 0; for (boxnum=0; boxnum <= 12; boxnum++){ document.cform.criteria[boxnum].checked = true; } } I also have a button that submits the values of all selected checkboxes to a php form. This I've also achieved. Form with button: <FORM action="http://localhost/mycode.php" name=optionsform METHOD="POST"> <input type="checkbox" name="criteria[]" value="check1"> <input type="checkbox" name="criteria[]" value="check2"> <INPUT TYPE=SUBMIT VALUE="SORT" > </form> The problem I am not able to do both of them with the same script. That is when selecting all boxes using javascript, I have to name the checkboxes as "criteria". But for the php to work I have to name them as "criteria[]". I can change this to "critera[]" but then I have to use $_GET but I'd rather use $_POST. So any suggestions on how I can work around this? Any help is appreciated, thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.