niche Posted May 10, 2012 Share Posted May 10, 2012 (edited) This is my first completely original JS. Why is my italian button so small? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="description" content="Save money" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><title>subcat</title><script type="text/javascript">function subcat() { var div = document.getElementById('subcat'); //get the container on the page div.innerHTML = ''; //clear out the subcat var new_subcat = document.createElement('form'); //create form new_subcat.action = "italian.php"; new_subcat.id = "italian"; var new_subcatB = document.createElement('button'); //create button new_subcatB.class = "button"; new_subcatB.type = "input"; div.appendChild(new_subcat); //div.appendChild(new_subcatB); //document.getElementById('italian').innerHTML=new_subcatB; document.getElementById('italian').appendChild(new_subcatB);}</script><style type="text/css">.button {padding:0px;width:82px;height:40px;vertical-align:top;}</style></head><body><?phpecho '<div style="float:left;height:100px;width:350px;background:yellow;">'; echo '<div style="float:left;height:40px;width:350px;background:pink;">'; echo '<button class="button" onclick="subcat()" >restaurants'; echo '</button>'; echo '</div>'; echo '<div id="subcat" style="float:left;height:40px;width:350px;background:Aqua;">'; echo '</div>';echo '</div>';?> </body></html> Edited May 10, 2012 by niche 1 Link to comment Share on other sites More sharing options...
Ingolme Posted May 10, 2012 Share Posted May 10, 2012 You should be setting the className property here: new_subcatB.class = "button"; 1 Link to comment Share on other sites More sharing options...
niche Posted May 10, 2012 Author Share Posted May 10, 2012 isn't that what I did? Link to comment Share on other sites More sharing options...
eTianbun Posted May 10, 2012 Share Posted May 10, 2012 (edited) new_subcatB.className='button' Edited May 10, 2012 by eTianbun 1 Link to comment Share on other sites More sharing options...
eTianbun Posted May 10, 2012 Share Posted May 10, 2012 (edited) new_subcatB.type='input' Does the <button> attr (type) have the property 'input'? I have'nt seen that before: Button Submit Reset Edited May 10, 2012 by eTianbun 1 Link to comment Share on other sites More sharing options...
niche Posted May 10, 2012 Author Share Posted May 10, 2012 Oops. Thanks for your help Ingolme and eTianbun. Link to comment Share on other sites More sharing options...
niche Posted May 10, 2012 Author Share Posted May 10, 2012 (edited) new_subcatB.type='input' Does the <button> attr (type) have the property 'input'? I have'nt seen that before: How would you do it? This works in FF not in IE. Edited May 10, 2012 by niche Link to comment Share on other sites More sharing options...
ShadowMage Posted May 10, 2012 Share Posted May 10, 2012 You could probably remove that line and it will behave the same. input is not a valid value for the type attribute on the button, so the browser will treat it as though the type were set to button. Same as if the type attribute were omitted altogether. 1 Link to comment Share on other sites More sharing options...
niche Posted May 10, 2012 Author Share Posted May 10, 2012 Simple enough. Thanks ShadowMage and thanks again Ingolme and eTianbun for your help with a very satisfying topic. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now