matfish Posted June 21, 2007 Share Posted June 21, 2007 Not sure if this is the right place to post, so I apologise in advance. Iv been using: http://validator.w3.org to validate my HTML (HTML but im using php...) Its throwing a wobbley because the id="title" of an input box has the same id as another, but this is because its in a php loop. I cant put a numeric variable on the end of it like: id="title1" id="title2" from the loop as Im using AJAX to pick up these values for posting. Any ideas? On another note, I have an <a href tag with onmouseover and onlick - but its saying this is an error too - but dont understand why? Im very sloppycode, so any understanding of this would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/ Share on other sites More sharing options...
matfish Posted June 21, 2007 Author Share Posted June 21, 2007 Also: Iv got: <input type="image" src="/images/cancel.jpg" name="cancel" id="cancel" value="Cancel" onClick="Javascript:window.close();" /> Line 159 column 132: there is no attribute "onClick". So how would i close the window with a button otherwise? Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279209 Share on other sites More sharing options...
jcombs_31 Posted June 21, 2007 Share Posted June 21, 2007 Just use a class .title that can be resused as many times as you want. As far as the anchor, show us the exact code you are using... If you are using xhtml you need to keep it all lower case, change it to onclick as far as putting this in the right place, you would probably be better off using the html and css forums, but I hope this gives you your answer. Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279211 Share on other sites More sharing options...
ober Posted June 21, 2007 Share Posted June 21, 2007 IDs have to be unique. How are you grabbing different fields if they're all named the same?!?! Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279250 Share on other sites More sharing options...
jcombs_31 Posted June 21, 2007 Share Posted June 21, 2007 I figured you are just using the id for the styling. I assume the name attribute is different. In any case, as ober said, your ids have to be unique, but for styling you can do what I suggested. Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279291 Share on other sites More sharing options...
matfish Posted June 21, 2007 Author Share Posted June 21, 2007 Hey thanks for the replies. lower-casing the mouseovers/onclicks worked thanks. I have a form which is being repeated (using edit in place with Ajax) so when I press submit, it takes the form_name[id] and then gets the id=title and id=body of that form for validation before posting but these are the things that are being repeated. I will re-check my coding as I understand id's have to be unque now - may have a work around. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279304 Share on other sites More sharing options...
matfish Posted June 21, 2007 Author Share Posted June 21, 2007 Hey, this is more of a CSS issue and I will post elsewhere, but just wondering as its along the lines of validation. I have: <style type="text/css"> #comment_error<?=$slap_detail['slapID']?> {float:left; color:#FFFFFF; padding:2px 2px 2px 2px; margin-top:2px; width:226px; border:1px #000099 solid; } .comment_error_msg<?=$slap_detail['slapID']?> { width:223px; border:0px #003366 solid; background-color:#458CCC; padding-left:3px; border:1px #FF0000 solid; color:#FFFFFF;} </style> which is in a loop as depending on where the error is, is dependant on the id. This works, but the html validator says I cant put this outside of the head tag. Is there anyway of looping in a css document or shall i just repeat the query in the head which will output the css first? Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279319 Share on other sites More sharing options...
ober Posted June 21, 2007 Share Posted June 21, 2007 I think you might be misunderstanding the usage of CSS. If the contents of the class or ID never change, why do you have more than one name for it? Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279322 Share on other sites More sharing options...
matfish Posted June 21, 2007 Author Share Posted June 21, 2007 Think I understand where your comming from now.. Iv got a form, which is repeated in a loop. If I press submit on the first one, javascript validates it (getelementbyid) which it highlights the box, I would then need id=title1 as this is the first form. Wouldnt both forms light up if I getelementbyid id=title ? withour any ID's after it? Many thanks. ps: I think i know what you mean now, as it will use the form id/name to get id=title ? and wouldnt need the number after it? Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279326 Share on other sites More sharing options...
ober Posted June 21, 2007 Share Posted June 21, 2007 I'm not sure how you're doing your JS call, but you could easily pass the names of the specific items to the script through an onclick or onsubmit event. If you're validating all the forms at the same time, you can dynamically grab all the elements on the entire page and just loop through them. If you need to change the style of any of those items, you can reference the offending item and modify it through JS. Post in the JS board... someone can help you get this sorted. Quote Link to comment https://forums.phpfreaks.com/topic/56528-htmlcss-validator/#findComment-279337 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.