Jump to content

twome

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

twome's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My javascript function 'toggleMenu' code is not collapsing and expanding the items I want. I have a long form and one of the headings is "Basics", I want the items underneath "basics" to display when basics is clicked and disappear when basics is clicked again. I think the problem is because the div tags are in between a table (Basics is in the middle of a table) Take a look.... (I encourage you to copy the code and put it in a file, save it and run.... see it doesn't work!!!) Any suggestions?? [code] <html> <head> <script LANGUAGE="JavaScript"> function toggleMenu(objID) {   if (!document.getElementById) return;       var ob = document.getElementById(objID).style;       ob.display = (ob.display == 'block')? 'none': 'block';       alert (ob.display); } </SCRIPT> <style type="text/css"> <!-- .mC {margin:5px; float:left;} .mH {color:#60c; cursor:pointer; font-weight:bold;} .mL {display:none; margin-bottom:10px;} .mO {display:block;} --> </style> </head> <body> <form action="processProfile.php" method="post" name="main"> <table width="756" height="91" border="0">   <tr>     <td> </td>     <td> </td>     <td bordercolor="#CCCCCC"><strong>Create/edit your profile ...</strong></td>   </tr> <!--.... ..... ...... .... ..... ......form fields here .... ..... ...... --> <tr bordercolor="#CCCCCC">         <td colspan="6"><div class="mH" onclick="toggleMenu('menu1')">Basics</div>               <hr/></td>       </tr>       <div id="menu1" class="mL">       <tr>         <td width="16%" rowspan="2" valign="top">Height:</td>         <td width="1%" rowspan="2"> </td>         <td colspan="4">Between           <select name="heightStart" id="heightStart" class="mO">             <option value="3">3'1"</option>             <option value="4">3'2"</option>             <option value="5">3'3"</option>               </select>           and           <select name="heightEnd" id="heightEnd" class="mO">             <option value="3">3'1"</option>             <option value="4">3'2"</option>             <option value="5">3'3"</option>           </select></td>       </tr> </div> <!--.... .... ...... ..... ..... rest of the table here . .... .... ...... ..... ...... --> </table> </form> </body> </html> [/code]
  2. I like the idea of the collapsible heading. How can I do the same thing on my website as on phpfreaks.com under "Poll Options" as displayed on the "Post a New Topic Form"? I uploaded a picture so you can better understand what I am trying to ask. Take a look at the screen shots... Any suggestions anyone?? [img src=\"http://www.eyedeaweb.com/pictures/phpfreaks.JPG\" border=\"0\" alt=\"IPB Image\" /]
  3. I have an item that I get from the database, it's a string separated by commas. To get the individual pieces I use the explode command. I would like the array index to be the same value as the exploded pieces. How can I do that? I imagine I would have a for each loop? Any suggestions? Here's what I have so far: [code] $query = "SELECT name, address, type FROM member m INNER JOIN profile p ON "; $query .= "m.memberID = p.memberID WHERE m.memberID = '".$sessUserID."'";          $dbResults = mysql_query($query); $result = mysql_fetch_array($dbResults);          $pieces = explode(",", $result['type']); print_r ($pieces); [/code] [u]Output[/u] Array ( [0] => 1 [1] => 5 [2] => 10 [3] => 12 ) [u]What I want the array to look like is this[/u]: Array ( [1] => 1 [5] => 5 [10] => 10 [12] => 12 ) [u]Ultimately, I have a group of checkboxes on a form[/u]: <input name="type[]" type="checkbox" value="1" /> <input name="type[]" type="checkbox" value="2" /> <input name="type[]" type="checkbox" value="3" /> ........ <input name="type[]" type="checkbox" value="14" /> Pretty much, I need to match the values in the array with the checkboxes -- if there is a match then display that checkbox as "checked". So according to the array results in the above example the checked check boxes would be: <input name="type[]" type="checkbox" value="1" checked="checked" /> <input name="type[]" type="checkbox" value="5" checked="checked" /> <input name="type[]" type="checkbox" value="10" checked="checked" /> <input name="type[]" type="checkbox" value="12" checked="checked" />
  4. Ken, I'm not quite sure what you mean by "on the returned arrays". Could you clarify? Thanks, -Coby [!--quoteo(post=367525:date=Apr 22 2006, 04:53 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 22 2006, 04:53 PM) [snapback]367525[/snapback][/div][div class=\'quotemain\'][!--quotec--] If you uses sasa's code for your form, all you have to do is use the count() on the returned arrays since only those check boxes that are actually checked are returned. Ken [/quote]
  5. Actually, I wanted to know not how many boxes the user selected, rather how many boxes there are in that group. (I have a loop that I go through - I need to know how many times to cycle through the loop depending on the number of checkboxes in that group). For TypeN I would return a count of 4 checkboxes (total for that group TypeN). And for relationN I would return 5 checkboxes (total in that group for relationN). For example: <input name="Type1" type="checkbox" id="Type1" value="checked" /> <input name="Type2" type="checkbox" id="Type2" value="checked" /> <input name="Type3" type="checkbox" id="Type3" value="checked" /> <input name="Type4" type="checkbox" id="Type4" value="checked" /> <input name="relation1" type="checkbox" id="relation1" value="checked" /> <input name="relation2" type="checkbox" id="relation2" value="checked" /> <input name="relation3" type="checkbox" id="relation3" value="checked" /> <input name="relation4" type="checkbox" id="relation4" value="checked" /> <input name="relation5" type="checkbox" id="relation5" value="checked" /> Although, I tried your code - works great!!! Thanks! I'll keep that in mind (what you wrote previously) for good reference in case I need it. (I probably will).
  6. I have a huge FORM with mostly checkboxes. How can I get the number (count) of checkboxes per group. I'm guessing I would have to using something like count($_POST). So how can I determine the number of checkboxes in the group "TypeN" and then for the group "relationN", etc. For example: <input name="Type1" type="checkbox" id="Type1" value="checked" /> <input name="Type2" type="checkbox" id="Type2" value="checked" /> <input name="Type3" type="checkbox" id="Type3" value="checked" /> <input name="Type4" type="checkbox" id="Type4" value="checked" /> <input name="relation1" type="checkbox" id="relation1" value="checked" /> <input name="relation2" type="checkbox" id="relation2" value="checked" /> <input name="relation3" type="checkbox" id="relation3" value="checked" /> <input name="relation4" type="checkbox" id="relation4" value="checked" /> <input name="relation5" type="checkbox" id="relation5" value="checked" />
  7. Form Validation - If you are using Dreamweaver MX you can install a checkForm extension by going to www.yaromat.com. This can help with checking your fields for the right type of data before processing. PHP Query String - I came across this same problem on how to parse strings in php. Look at the following... //(parses the query string) //URL: [a href=\"http://www.php.net/manual/en/function.parse-str.php\" target=\"_blank\"]http://www.php.net/manual/en/function.parse-str.php[/a] $getID = parse_str($_SERVER['QUERY_STRING']); [!--quoteo(post=366703:date=Apr 19 2006, 09:55 PM:name=bpops)--][div class=\'quotetop\']QUOTE(bpops @ Apr 19 2006, 09:55 PM) [snapback]366703[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi all, Sorry if this question has been asked before, but I'm not really sure if there is an official name for what I'm trying to do. I'm creating a site in which a user enters a bunch of data into a form. But some fields I want people to be able to enter only numbers, some fields text is allowed, all fields I want to prohibit from HTML codes, and all fields will have a specific character number limit. My question is the best way to implement these rules. I'm guess there's a way to parse strings in php and check for certain things... Can someone please refer me to a php tutorial that would suit this? or even php code that I could take a look at and take what I need from? Or if there are easier ways to do this please let me know. Thanks in advance to all helpful replies! Bpops [/quote] [code]
×
×
  • 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.