HTML - Help Please: Xhtml And Multiple Forms
For years I have done things the same old way and they have worked fine, now I want to move a site over to xhtml from html4 and I am having problems get some code validated via W3C validator.
Here is a sample of the code. It has 3 forms on the page. Each form is for a particular product in the shopping cart. ie, each form is for a unique product and it comprises a hidden text field containing the product_code (eg AAA3) and a submit button. When the chosen form is submitted I just pick up the POSTed data from the product_code variable ($_POST['product_code']) in php. This works fine for last few years but under the w3C validator it complains that the id is not unique for the product_code Quote: ID "product_code" already defined How can I get round this without having individual "product_code" ID's eg (id="product_code1" id="product_code2") as this would make life very complicated trying to workout what product_code was submitted. HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> Here is Product - 1 <form id="form1" method="post" action=""> <p> <input type="hidden" id="product_code" value="AAA1" /> </p> <p> <label> <input type="submit" id="submit" value="Submit" /> </label> </p> </form> Here is Product - 2 <form id="form2" method="post" action=""> <p> <input type="hidden" id="product_code" value="AAA2" /> </p> <p> <label> <input type="submit" id="submit" value="Submit" /> </label> </p> </form> Here is Product - 3 <form id="form3" method="post" action=""> <p> <input type="hidden" id="product_code" value="AAA3" /> </p> <p> <label> <input type="submit" id="submit" value="Submit" /> </label> </p> </form> </body> </html> Similar TutorialsHey guys and thanks in advanced for helpin' me out with this one. Anyways, I'm building a sort of "Advanced" search functionality. I want to give the user the ability to select multiple checkboxes in different categories (forms) but to be able to account for each checkbox even though they are in different forms. For example a Newspaper might have a search for an article by: Code: <FORM>(form name = "formONE") Paper Type Weekly [] Daily [x] Monthly [] {SUBMIT BUTTON} </ FORM> <FORM> (form name = "formTWO") Location Upper East [] Null County [] Down South [x] {SUBMIT BUTTON} </ FORM> <FORM> (form name = "formTHREE") Article Section Lifestyle [] Sports [x] Weather [] Finances [] {SUBMIT BUTTON} </ FORM> SO looking at the above...If the user "checked" (I placed 'x' in there) those boxes...and clicked ANY of the submit buttons, I want to be able to pull-in EACH of the checked items from ALL THREE of the forms. What is happening now with my code, is I'm only getting the results for the form which I clicked the 'submit' button in. I know you might ask, "why not just put them in one form?"... but I have them in separate forms because I want the user to have the ability to "CHECK/UNCHECK ALL" for each category (i.e. Paper Type, Location, Article Section...) Is it as easy as just wrapping all of those forms in one GIANT form, and supply each submit button with the name of that GIANT form? I hope this makes sense, and let me know if you need anything else at all...it's the last piece of this search and I just want to get it out of the waY!! Thanks guys! I have a loop that extracts data out of the database and outputs a dropdown form with each line with options for the user. I have included an onChange = "this.form.submit();" for each dropdown. This works fine in Firefox, but does not work so well in Internet Explorer(yes, scripting is enabled). Here's the code: <form method="post" action="some.php"> <input type = "hidden" name ="variable1" value ="'.$variable1.'"' /> <input type = "hidden" name ="variable2" value ="'.$variable2.'"' /> <select name = "'.$variable1.$variable2" onChange = "this.form.submit();"> <option value = "option_1"> Option 1</option> <option value = "option_2"> Option 2</option> <option value = "option_3"> Option 3</option> <option value = "option_4"> Option 4</option> </form> This code is then just echo'd for each line. $variable 1 and $variable2 are unique, so to name each form differently I just give combine the two for a unique name I can call at some.php. Symptoms: In Mozilla this works great. With IE(both 6 and 7) the variable1 and variable 2 are passed along, however option_1(the 1st default option displayed) is always passed along except for the last one of my list. The last one of the list always passes along the correct the correct value. So if I had two outputs A and B,and I selected Option2 for each of them...then A would send Option1 but B would send the selected Option2. Hey Guys, I am having an issue where the only logical way I can see this being done, is with nested forms, which I know aren't allowed, and are breaking my design in IE. Here's the concept: I have a gallery of images that a user is managing (like 12 images are displayed on each page). Each image has a checkbox associated with it that the user can check and then at the bottom of the page the user can move all checked images to another folder. Therefore, all images and their checkbox's, along with the "move to folder" selection menu and submit button at the bottom are contained into one big form. Now within this form I have the option for users to move individual images. Each image has a select menu of folders and submit button that they can use to move a individual image. This therefore requires another form, just for this select menu (since I only want the action to be applied to this specific image and it's select input, and all others also have the same select input name, etc) and a submit button. See this screenshot for example: http://imagenerd.com/show.php?_img=gallery69SR.jpg Here is a snippet of code I am using in this example: Code: <form action="" method="post"> <div class="box-row last-row"> <div class="box-full"> <div class="box-top"><div class="box-bot"><div class="box-left"><div class="box-right"><div class="box-top-left"><div class="box-top-right"><div class="box-bot-left"><div class="box-bot-right"> <div class="box-content"> <h1>Folder: dafasd</h1> <div class="box-content-pad"> <div class="gallery-block"> <span class="edit-title" id="_199" title="edit title"><i>click to add title</i></span> <div class="image-option-links"> <a href="javascript:void(0);" onclick="share_codes_popup('/view-codes/?filename=siege_of_stormwynd-AXAP0.jpg&thumbname=th_siege_of_stormwynd-AXAP0.jpg', 'title');" title="get share codes">share</a> | <a href="javascript:void(0);" title="move this image" class="move_image">move</a> | <a href="/my-gallery/?delete_image=199" title="delete this image" onclick="return confirm('Are you sure you want to delete this image, siege_of_stormwynd-AXAP0.jpg?')">delete</a> </div> <div class="move-image-options"> <form action="" method="post"> <select name="move_image_folder"> <option value="1">Root</option> <option value="12">dafasd</option> <option value="13">dafasd</option> <option value="14">dafasd</option> <option value="15">asdfasdf</option> <option value="16">asdfasdf</option> </select> <input type="hidden" name="move_image_id" value="199" /> <input type="submit" name="move_image" value="Go" onclick="return confirm('Are you sure you want move this image, siege_of_stormwynd-AXAP0.jpg?');" /> </form> </div> <div class="image-box"> <a href="http://www.new.imagenerd.com/show.php?_img=siege_of_stormwynd-AXAP0.jpg" title="View siege_of_stormwynd-AXAP0.jpg" target="_blank"><img src="/thumbnails/th_siege_of_stormwynd-AXAP0.jpg" alt="siege_of_stormwynd-AXAP0.jpg" width="175" height="35" /></a> </div> <div> <table width="100%" cellpadding="0" cellspacing="0" class="image-select"> <tr> <td width="20" align="left"> <input type="checkbox" name="image_cb[]" value="199" class="checkbox" id="img_199" title="select siege_of_stormwynd-AXAP0.jpg" /> </td> <td align="left"><label for="img_199" title="select siege_of_stormwynd-AXAP0.jpg">siege_of_stormwynd-AXAP0.jpg</label></td> </tr> </table> <table width="100%" cellspacing="0" cellpadding="0" class="table-pad-2 table-align-td-left quick-select"> <tr> <td width="70"><b>Email/IM:</b></td> <td><input type="text" value="http://www.new.imagenerd.com/show.php?_img=siege_of_stormwynd-AXAP0.jpg" onclick="this.select()" /></td> </tr> <tr> <td><b>Forums:</b></td> <td><input type="text" value="" onclick="this.select()" /></td> </tr> <tr> <td><b>HTML:</b></td> <td><input type="text" value="<a href="http://www.new.imagenerd.com/show.ph...XAP0.jpg" target="_blank"><img src="http://www.new.imagenerd.com/thumbna...XAP0.jpg" alt="" border="0" width="175" height="35" /></a>" onclick="this.select()" /></td> </tr> <tr> <td colspan="2"><a href="/view-codes/?filename=siege_of_stormwynd-AXAP0.jpg&thumbname=th_siege_of_stormwynd-AXAP0.jpg" title="more share codes">more...</a></td> </tr> </table> </div> </div> . . (cut off other 2 gallery block divs due to forum character post restrictions) . <div class="clear"></div> </div> <div class="pager"> </div> </div> </div></div></div></div></div></div></div></div> </div> <div class="clear"></div> </div> <div class="box-row" style="margin: 12px 0px 0px 0px;"> <div class="box-full"> <div class="box-top"><div class="box-bot"><div class="box-left"><div class="box-right"><div class="box-top-left"><div class="box-top-right"><div class="box-bot-left"><div class="box-bot-right"> <div class="box-content align-center"> <p><b>With Selected Images:</b></p> <table cellpadding="0" cellspacing="0" align="center"> <tr> <td> <input type="checkbox" id="selectall" /> </td> <td width="120" align="left"> <label for="selectall">select/unselect all</label> </td> <td width="120"> <select name="action" id="action_select"> <option value="">----------</option> <option value="delete">Delete</option> <option value="move">Move to</option> </select> </td> <td width="120"> <select name="multi_folder" disabled="disabled" id="folder_select"> <option value="1">Root</option> <option value="12">dafasd</option> <option value="13">dafasd</option> <option value="14">dafasd</option> <option value="15">asdfasdf</option> <option value="16">asdfasdf</option> </select> </td> <td width="120"> <input type="submit" name="multi_action" value="Go" id="multi_go" disabled="disabled" onclick="return confirm('Are you sure you want to perform the selected action on all of the selected images?')" /> </td> </tr> </table> </div> </div></div></div></div></div></div></div></div> </div> <div class="clear"></div> </div> </form> Red - Associates with multi image options Blue - Associates with single image move option Any suggestions on how I can achieve this? Thanks, Kyle I'm new to forms and am trying to learn how to make a multiple page one. What I've made so far is very basic, but I figure I shouldn't make a pretty and complex one until I master the simple. I've made three separate pages: page a has the first part of the form and when you click 'continue' it should save the information and move you onto page b where you fill in another form. Then you move onto page c where the information you entered is displayed for you to review, then you press send. That's when it's sent to my e-mail. There are two problems with my code: when you click 'continue' on page A it automatically sends the info to my e-mail and I don't want it to. I want it to go to page b. It also displays the information entered on page a, but also shows a bunch of the code that should be hidden. I don't know why. And it's driving me nuts. I'd appreciate any help! Here's the code: <html> <head> <title>Sample Multiple Page Form</title> </head> <body bgcolor="white" text="#000000" link="#0000CC" vlink="#0000CC" alink="#0000CC" marginwidth=0 marginheight=15 topmargin=15 leftmargin=0> <form action="http://www.bluehost.com/bluemail" enctype="multipart/form-data" method="POST"> <input type="hidden" name="sendtoemail" value="contact@mywebsite.com"> <input type=hidden name="next_page" value="Multiple_Page_b"> <input type=hidden name="required" value="name:Name Required,email:e-Mail Address Required"> <input type=hidden name="current_page" value="Multiple_Page_a"> <input type=hidden name="form" value="2"> <input type=hidden name="start" value="1"> <center> <table width=450 cellpadding=4> <tr> <td colspan=2> <font size=2 face="arial" color=red> </td> </tr> <tr><td><font face="arial" size=2> Your Name: </td><td><input type=text name="name" value="" size=30> </td></tr> <tr><td><font face="arial" size=2> Email Address:</td><td><input type=text name="email" value="" size=30></td></tr> <tr><td colspan=2><br><input type="submit" name="next" value="Continue >>"></td></tr> </table> </form> </body> </html> And here's the message displayed when clicking continue: Thank you for completing our form. The following info was sent to contact@mywebsite.com: Field Value next_page Multiple_Page_b required name:Name Required,email:e-Mail Address Required current_page Multiple_Page_a form 2 start 1 name Jess email contact@myemail.com next Continue >> We're having difficulties dealing with two forms on one html search results page. We want the following to happen: 1) "next" and "previous" links to appear when the search returns more results than the limit set in the code. 2) the user to be able to click on a link/radio button which would allow them to view complete result data on another page. The code for goal 1 seems to need a "method = get" capability, while the second goal needs "method = post" to pass information on to the next page. We thought that the best way to do this would be to have two separate forms on the one html page. However, we can't seem to get either form to work in its entirety. Here's the code for our form with the "next" and "previous" links: Code: <form name = "form2" id="form2" method="get" action="<?php echo $_SERVER['PHP_SELF']?>"> When there is only this form on the page, the next/previous links work fine. It's when we try to incorporate other buttons (such as a submit button) and another form that things get messy. The same is true for the other form... it works fine by itself, but it's the combination that throws it off. Goal 2 form: Code: <form name = $formNum id = $formNum method=post action=seach_match_result.php target='_blank'> (This form has a submit button at the end.) These forms are not nested, but totally separated in the code. Are we on the right track, or is there a better way to accomplish this? Thanks! AM I am using the following code to submit two forms at the same time - Code: <body onLoad="document.forms[0].submit();document.forms[1].submit();"> <form action="form1.php" method="post" target="_self"> <input type="hidden" name="value1" value="value1"> </form> <form action="form2.php" method="post" target="_blank"> <input type="hidden" name="value2" value="value2"> </form> </body> This does work and the current page goes to the first form's action, but the second form is opened in a new window. This is caused by the target="_blank" but if I don't include this, only the first form is sent. Is there any way I can make the second form run but not follow it (ie make it run in the 'background') or suppress the new window from opening? These two forms have to be separate and use POST, not GET. I only want to follow the first form. (That brings up another question - is it possible to not follow a form at all?) Thanks! Hey everyone, I'm working on a new login form for my site and getting a HUGE headache from it. The login box houses 2 forms but I do some trickery with jQuery for the password field so that I can display the word "Password" in a text input, and then I swap it to a password type input field when the user focuses on it. - The form for logging in contains: Email field [type=text] Fake Password field [type=text] Actual Password field[type=pass] - Another to create a new account contains: Screename [type=text] Email[type=text] Password field[type=pass] Testing in FireFox, I clear the saved passwords/cache from the site, pull up the forms and submit the LOGIN form. It's successful and I choose to "Remember the password". Now I logout and pull up the forms again...and the SIGN UP form's password field, now contains the value I entered in the LOGIN form when I saved earlier. Does it simply look for all password fields on the page and add the value to them? The forms both have different ID's all the input fields have different ID's... I've never dealt with forms on this magnitude, so it may be easy, but man is it a headache! THANKS FOR ANY HELP! Hello all, Iam trying to use for loop / while loop (javascript) to create multi HTML input forms, but I have no idea how to do. Please help me out. Thank you! Daralis Which one is better? XHTML STRICT 1.0 or XHTML 1.1 hi and goodafternoon i run wapsites and i want to convert the wml scripts to xhtml all my scripts are php based which i know will work in xhtml too. i also use mysql coding for database side of things . here is one of my smaller scripts . <?php <wml> <card title="sitename"> <p align="center"> <img src="logo.gif" alt="logo"/><br/> Welcome!!<br/><br/><a href="login.php"><img src="login.gif" alt="Login"/></a><br/><a href="terms.php"><img src="register.gif" alt="Register"/></a><br/> <br/> <big><b><a href="terms.php">Terms of use!</a></b></big> <br/> You are here with<br/> END; print 'Browser:'; $browser = explode ('/', $HTTP_USER_AGENT); print $browser[0]; print '<br/>'; print "IP-Adress: $REMOTE_ADDR<br/>\n"; print <<<END ---<br/> </p> </card> </wml> END; ?> how would i convert that to xhtml . and if its just a case of changing the tags then would it work on the rest of the scripts with sql coding in too . nclemale@hotmail.com or post your replies here thanks in advance hello friends , I want to know that what is what is XHTML ? plz anybody help me . I want to know about this . Thankx ==== Tell me..... can make dynamic website in xhtml so xhtml elements should always be in lowercase how does this extend to the case in css. for example if im using a xhtml doctype should i be using lower case color values like color:#ffffff vs color:#FFFFFF. I know as per a hexidecimal value "ffffff" is the same as "FFFFFF" and the same as "fFfFfF". they are all equal to the same value so it really doesn't matter but does the xhtml doctype dictate that these values should be in lowercase? Please anybody tell me about the XHTML. I am reading about XHTML now and noticed that it is really no different than HTML. The only difference(s) are, correct me if I'm wrong, that XHTML is more strict with the rules. Lowered-cased letters, properly closed tags, etc, all that mumbo jumbo. If I'm already doing that with HTML, must I need to worry about XHTML? Hi. I *hate* I.E. I'm usually browsing websites in Google Chrome - & sometimes Mozilla / Opera. Ive designed a website (not public as yet), & it does validate for XHTML - it looks perfect on Opera / Mozilla & Chrome. But IE messes it up. Basically it uses Divs, & has a left menu, & the main content is a Google map. Also, top menu / banner & a footer at the bottom.. on IE7, the google map is UNDER the list of cities etc (left menu), instead of in the middle / right of the left menu.. Can anyone advise a website listing common IE problems & how web designers can fix it.. what is xhtml? I'm pretty new to XHTML and I see that to properly close a br tag (and others), you usually put a space, then a slash, then a closing chevron, a la <br />. But I was wondering if there is anything fundamentally wrong with eliminating the space before the slash. It seems to work in my browser either way, and I think it makes the code a little easier to read and type. Thanks! What is the difference between HTML and XHTML? What are the benefits and is it worth learning? Thanx 4 the help! |