JavaScript style.height not working [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 4 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I'm trying to set the height of div on my page, because my page content is dynamic. But it don't work.
CSS:
<style type="text/css">
#figmenu {
height: 50px;
}
</style>
JS:
<script type="text/javascript">
function HeightUp() {
var fm = document.getElementById('figmenu');
fm.setAttribute('style', 'height: 500px');
// fm.style.height = '500px';
}
</script>
HTML:
<body>
<div id='cssmenu' onclick=HeightUp();>
<input type="submit" name="change" value="First Button" id="figs"/>
<input type="submit" name="change" value="Second Button" id="tr"/>
<input type="submit" name="change" value="Third Button" id="fbp"/>
</div>
<div id='figmenu'>
<input type="submit" name="change" value="4th Button" id="b4"/>
<input type="submit" name="change" value="5th Button" id="b5"/>
<input type="submit" name="change" value="6th Button" id="b6"/>
</div>
</body>

Your code is working, as you can see in this FIDDLE
When your code execute this line, you will see the background getting bigger:
fm.style.height = '500px';

check whether the page has any other html element contains same id name "figmenu"
in a page there should not be two ids with a same name

Related

Why isn't my text changing color? (Javascript) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Trying to change the color of the text with javascript - here is what I have
<input name="text" value="black" id="black" type="radio" onclick="changetextcolor(this);">"Black"
<input name="text" value="purple" id="purple" type="radio" onclick="changetextcolor(this);">"Purple"
<input name="text" value="lightpink" id="lightpink" type="radio" onclick="changetextcolor(this);">"Light Pink"
function changetextcolor(element){
document.body.style.Color = element.value;
};
here is the web page I am working on http://www.acsu.buffalo.edu/~mariaroo/validation.html
You have to put color property in lowercase and not with capital letters.
color and not Color.
function changetextcolor(element){
console.log(element.value);
document.body.style.color = element.value;
};
<input name="text" value="black" id="black" type="radio" onclick="changetextcolor(this);">Black
<input name="text" value="Purple" id="purple" type="radio" onclick="changetextcolor(this);">Purple
<input name="text" value="lightpink" id="lightpink" type="radio" onclick="changetextcolor(this);">Light Pink
You're changing the wrong property in your code. It should be document.body.style.color (note all lowercase color).
You mixed something up.
You can not use a .text property for styling the color of your text.
Try .color instead. This should work.
function changetextcolor(element){
document.body.style.color = element.value;
};

HTML5 form button onsubmit not working [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have a simple form with two HTML5 buttons. Each button submits the form to a different php page. This is working well, but the 'onsubmit' function is never triggered. I want to show a dialog box before the delete.php page is called.
<form method="post">
<input type="text" name="fname">
<!-- HTML5 FORMACTION -->
<button type="submit" name="update" formaction="update.php">Update</button>
<button type="submit" name="delete" onsubmit="return confirm('Do you really want to delete?');" formaction="delete.php">Delete</button>
</form>
I have tried different variations, but the javascript code is never triggered. Why?
Buttons don't have submit events, forms do.
Buttons have click events.
onsubmit is valid for a form, not for a button. You will have to use onclick instead of onsubmit.
try like this
<form method="post">
<input type="text" name="fname">
<!-- HTML5 FORMACTION -->
<button type="submit" name="update" formaction="update.php">Update</button>
<button type="button" name="delete" onclick="return delete();" formaction="delete.php">Delete</button>
</form>
<script>
function delete(){
if(confirm('Do you really want to delete?')){
// delete code
}
return false;
}
</script>

Add a <li> tag in jquery wont work [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
here is my table:
<ul class="vertical-tabs-list">
<li class="vertical-tab-button first selected">blah</li>
<li class="vertical-tab-button">blah</li>
</ul>
I want to append another li like so:
$(".vertical-tabs-list").append('<li><input type="submit" name="op" id="edit-save" value="Save" class="form-submit"</li>');
What am I doing wrong?
Try this
$("ul.vertical-tabs-list").append('<li><input type="submit" name="op" id="edit-save" value="Save" class="form-submit" /></li>');
This has HTML with no syntax errors and a more specific selector. If that doesn't work check to make sure you have jquery properly linked up with your page.
Also, are you using a document ready function?
$(document).ready(function() {
//your code here
$("ul.vertical-tabs-list").append('<li><input type="submit" name="op" id="edit-save" value="Save" class="form-submit" /></li>');
});

link button using html5 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want to create a button which allows me to go to a link entered in an input filed.
So this is what I did but it does not work.
<html>
<head>
</head>
<body>
<form action="link">
link : <input type="text" id="link">
<input type="button" value="go" onclick="self.location.href = 'docuement.getElementById('link').value'"/>
</form>
</body>
</html>
What should I do?
Don't use a string literal, get rid of the ' from around the value you assign to self.location.href.
Spell document correctly
You should avoid using self as well, it is an unnecessary level of indirection.
<input type="button" value="go" onclick="location.href = document.getElementById('link').value"/>
Things fixed:
fix spelling of document
unquote the expression to be evaluated
don't bother with self

Display everything in one row css [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I am trying to put 2 different div's in one row.
I tried creating a new div with display:inline/inline block both, but still they are still displayed in next line.
How can I use CSS o display everything in one row.
<div id ="yourwrapper">
<FORM NAME="myform" ACTION="" METHOD="GET">
Box Name:
<SELECT NAME="list1" ID="list1">
<OPTION>CD1</OPTION>
</SELECT>
<INPUT TYPE="button" NAME="button" VALUE="New" onClick="AddItem1()"/>
<INPUT TYPE="button" NAME="button" VALUE="Delete" onClick="DeleteItem1()"/>
<INPUT TYPE="button" NAME="button" VALUE="Copy" onClick="CopyItem1()"/>
</div>
You can also try
#yourwrapper {
whitespace: no-wrap;
}
which will tell the css not to wrap the elements, and they'll go off the page.
Try this:
#yourwrapper > div{
float:left;
}
Use span rather than divs if you plan to use inline elements. To make elements align to each other use rather float:left (and then clear in the end) or display:inline-block.

Categories