Get value from button

B

bonAveo.net

Hi,
I got 3 buttons with 3 different values...
<input type="image" src="search.png" value="http://jigsaw.w3.org/css-validator/validator?usermedium=all&uri=" onclick="addUrl(this.value)">
<input type="image" src="search.png" value="http://validator.w3.org/check?uri=" onclick="addUrl(this.value)">
<input type="image" src="search.png" value="http://validator.w3.org/checklink?h...ype=all&recursive=on&depth=1&check=Check&uri=" onclick="addUrl(this.value)">

....and I want the value from the button pressed into this:
function goTo() {

var adress = document.getElementById("seee");
var link = document.getElement("addUrl");

var url = link + adress;
(...something, something...)
}

What have I done wrong?
 
D

Daniel Kirsch

bonAveo.net said:
Hi, I got 3 buttons with 3 different values...

where is your addUrl function?

You may probably want something like

function addUrl(val) {
document.getElementById("seee").value += val;
}


I don't see an element with ID "seee"


I don't see an element with ID "addUrl"


"link" and "adress" are object references in this case. If they
reference a button, you need to get their values:


var url = link.value + adress.value;

Daniel
 
B

bonAveo.net

OK; heres my "whole" code:

function goTo() {

var adress = document.getElementById("seee");
var link = document.getElement("addUrl");

var url = link + adress;
alert(url);
if (window.widget) widget.;
site.value="";
}



....and...


<form class="felt" method="get" action="javascript:goTo()">
<!-- Searchfield -->
<input id="seee" type="text" size="16" maxlength="255" value="" />
<!-- Searchfield end -->
<br />
<input type="image" src="search.png"
value="http://jigsaw.w3.org/css-validator/validator?usermedium=all&uri="
onclick="addUrl(this.value)">
<input type="image" src="search.png"
value="http://validator.w3.org/check?uri="
onclick="addUrl(this.value)">
<input type="image" src="search.png"
value="http://validator.w3.org/checklink?h...ype=all&recursive=on&depth=1&check=Check&uri="
onclick="addUrl(this.value)">
</form>


I don't understand why the value from the pressed button don't aply in
the JavaScript.
 
L

Lee

bonAveo.net said:
OK; heres my "whole" code:

function goTo() {

var adress = document.getElementById("seee");
var link = document.getElement("addUrl");

var url = link + adress;
alert(url);
if (window.widget) widget.;
site.value="";
}



...and...


<form class="felt" method="get" action="javascript:goTo()">
<!-- Searchfield -->
<input id="seee" type="text" size="16" maxlength="255" value="" />
<!-- Searchfield end -->
<br />
<input type="image" src="search.png"
value="http://jigsaw.w3.org/css-validator/validator?usermedium=all&uri="
onclick="addUrl(this.value)">
<input type="image" src="search.png"
value="http://validator.w3.org/check?uri="
onclick="addUrl(this.value)">
<input type="image" src="search.png"
value="http://validator.w3.org/checklink?h...ype=all&recursive=on&depth=1&check=Check&uri="
onclick="addUrl(this.value)">
</form>


I don't understand why the value from the pressed button don't aply in
the JavaScript.

You seem to be making wildly incorrect guesses about what should work.
You still haven't shown any code for your addUrl() function.
Are you expecting getElement("addUrl") to return the argument passed to that
(undefined) function? It doesn't work that way.
You should very rarely use an input of type image unless you want clicking on it
to submit a form.
You shouldn't have a javascript function as the action of your form.
You seem to be trying to generate an URL by concatinating a reference to an
input element with a reference to a function.
The last two lines of your function goTo() don't make any sense at all.
 
D

Daniel Kirsch

bonAveo.net said:
var url = link + adress;

Once again.
"link" and "adress" are object references in this case. If they
reference a button, you need to get their values:

var url = link.value + adress.value;

However I still don't see any element with id="addUrl" so

var link = document.getElement("addUrl");

will probably not even contain a valid reference.

Daniel
 
R

Randy Webb

Daniel said:
Once again.
"link" and "adress" are object references in this case. If they
reference a button, you need to get their values:

var url = link.value + adress.value;

However I still don't see any element with id="addUrl" so

var link = document.getElement("addUrl");

will probably not even contain a valid reference.

Even if addUrl existed, document.getElement(anything) wouldnt contain a
valid reference unless getElement was a author-defined function.
document.getElementByID('addUrl') might contain a valid reference though.
 
D

Daniel Kirsch

Randy said:
Even if addUrl existed, document.getElement(anything) wouldnt contain a
valid reference unless getElement was a author-defined function.

Absolutely.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top