473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Get value from button

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?hide_redirects=on&hide_type=all&recursiv e=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?

Jul 23 '05 #1
6 16103
bonAveo.net wrote:
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?hide_redirects=on&hide_type=all&recursiv e=on&depth=1&check=Check&uri="
onclick="addUrl(this.value)">
where is your addUrl function?

You may probably want something like

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

function goTo() {

var adress = document.getElementById("seee");
I don't see an element with ID "seee"

var link = document.getElement("addUrl");
I don't see an element with ID "addUrl"

var url = link + adress;


"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
Jul 23 '05 #2
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?hide_redirects=on&hide_type=all&recursiv e=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.

Jul 23 '05 #3
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?hide_redirects=on&hide_type=all&recursiv e=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.

Jul 23 '05 #4
bonAveo.net wrote:
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
Jul 23 '05 #5
Daniel Kirsch wrote:
bonAveo.net wrote:
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.


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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #6
Randy Webb wrote:
Even if addUrl existed, document.getElement(anything) wouldnt contain a
valid reference unless getElement was a author-defined function.


Absolutely.
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Yaqian Fang | last post by:
Hi, could anyone please tell me how to make a button look like "being clicked"? A button picture always looks static, though a link is associated with it. Thank you.
9
by: glin | last post by:
Hi Guys, I am having problem finding the position of a button that I can set the div position next to the button. Can you please help? Thanks in advance.
3
by: Adam | last post by:
Hey guys, I've decided to stop banging my head against the wall and just ask you guys for the answer. I can't seem to find it. I have a form in which I have multiple submit buttons; only, I'm...
2
by: chris | last post by:
i have a form with 3 buttons with a text box next to each button what i want to do is when a textbox is filled out the default button is changed to the button next to that text box rather than...
4
by: Chua Wen Ching | last post by:
Hi there, button1.Value = true/false 'in vb6 how to code that in c#? Any help please? I cannot find the value properly for buttons in c#. I not sure what to replace value for buttons? ...
2
by: Sedef | last post by:
Hi, i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for...
28
by: AndyZa | last post by:
The following html creates a page with two input buttons - the first is a small button and the second is a much larger button because it has a longer value. In Internet Explorer 6 the second button...
2
by: sathyashrayan | last post by:
Dear group, My question may be novice. I have seen codes where the isset() is used to test weather a user's session ($_SESSION) is set before entering a page. A kind of direct access to a page is...
22
by: divina11 | last post by:
I'm building a program where you have an input box and an button, when user presses the button, the button value is displayed on the input box. I've tried the following: function...
1
by: abcdriver | last post by:
Later edit: Too complex: The only thing I should know is: The submit button's NAME (and value) will only be sent if that particular button was used to submit the form, so you should be able to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.