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
Related
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 last year.
Improve this question
The error ReferenceError: b is not defined at HTMLButtonElement.onclick (/:32:30)
let s;
function b(){
s = document.getElementById(k).innerHtml;
animates();
}
<form class="form">
<label>How much do you want to donate</label>
<input type="number" id="k">
<button id="l" onclick="b()">Cal</button>
</form>
no need to do a form for this, also inline events are not preferred use eventListeners in js.
NOTE: I've put input's value as result, but you didn't say what you exactly want, so I think this will work with you anyway
document.getElementById('l').addEventListener('click', function() {
document.getElementById('result').innerHTML =document.getElementById('k').value;
})
<label>How much do you want to donate</label>
<input type="number" id="k">
<button id="l">Cal</button>
<p id="result"></p>
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 5 years ago.
Improve this question
This is a copy of an HTML document from a tutorial on Javascript. Upon opening it in Chrome, it doesn't behave as intended. When I click the button with Set Cookie written on it, nothing shows up, regardless of whether I have written something in the box (we should get output on the page) or not (we should get an alert). Why?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
<!--
function WriteCookie()
{
if( document.myform.customer.value == ""){
alert("Enter a name");
return;
}
cookievalue = escape(document.myform.customer.value) + ";";
document.cookie="name=" + cookievalue;
document.write("Setting Cookies : " + document.cookie);
}
//-->
</script>
</head>
<body>
<form name="myform" action ="">
Enter name: <input type="text" name="customer"/>
<input type="button" value="Set Cookie" onlick="WriteCookie();"/>
</form>
</body>
</html>
You have a typo in your input box. It should read:
<input type="button" value="Set Cookie" onClick="WriteCookie();"/>
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>');
});
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'm trying to set the value of a text input field when someone clicks anchor/button. Right now I have this:
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#text-add").click(function(){
$("#domain-pick").val("test");
});
});
</script>
</head>
<a id="text-add" href="javascript:void(0);">Click Here</a>
<input type="text" name="text-field" id="domain-pick">
I got it working in Jsfiddle, but it will not work on my wordpress site!
Please refer this fiddle.
Note:
You don't need to wrap the function in document.ready if you are
script appears after the markup.
Please avoid inline javascript, like javascript:void(0);
Markup:
<a id="text-add" href="#">Click Here</a>
<input type="text" name="text-field" id="domain-pick">
JS:
$("#text-add").on('click', function(e){
e.preventDefault();
e.stopPropagation();
$("#domain-pick").val("test");
});
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.