Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form element coming up as undefined 1

Status
Not open for further replies.

billycat

MIS
Apr 28, 2005
22
US
I have a radio button named R1 .. but when i call it, it comes up as undefined.
Code:
<input type="button" class="formfield" value="submit" onClick="window.location=self.location.href.split('?')[0] + '?row=' + document.myform.mylist.value + '&value=' + this.form.values.value + '&set=1' + '&r1=' + document.myform.R1.value;">
 
Hi

Let us color it up abit.
Code:
[red]<[/red][purple][b]input[/b][/purple] [blue]type[/blue]=[i]"button"[/i] [blue]class[/blue]=[i]"formfield"[/i] [blue]value[/blue]=[i]"submit"[/i] [blue]onClick[/blue]=[i]"window.location=self.location.href.split('?')[0] + '?row=' + document.myform.mylist.value + '&value=' + this.form.values.value + '&set=1' + '&r1=' + document.myform.R1.value;"[/i][red]>[/red]
Now go and give it a [tt]name[/tt] attribute...

Feherke.
 
this is the radio
Code:
		<input type="radio" value="AND" name="R1" id="R1"><b><font size="1">AND</font></b>
	
	
		<input type="radio" value="OR" name="R1" id="R1"><b><font size="1">OR
		
		</font>
 
So... you have 2 radio buttons... sharing the same ID. This is not valid markup (IDs are supposed to be unique). They can share the same name, but they cannot share the same ID.

See if removing the ID fixes it for you :)

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
This:

Code:
document.myform.R1.value;

should be:

Code:
document.myform.R1[!][0][/!].value;

to access the first radio, or this:

Code:
document.myform.R1[!][1][/!].value;

to access the second.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I did that, and this.form.R1.value = undefined still.
 
ok i got that working... now would i tell which one was clicked?
 
On the very end of your query string:

Code:
&r1=' + document.myform.R1.value;">

I recommend making a global variable whose value is set to the currently checked radio button. Put an onclick handler on each radio button that will check to see which button is checked and then reset the global variable if needed.

Then on your query string, you only need to add that variable to the end:

Code:
&r1=' + globalVariable">


[monkey][snake] <.
 
ok so this is my attempt.
Code:
var r1 = 1;
function value(a) {
a = r1
return r1
}
then this is my radio
Code:
		<input type="radio" value="AND" name="R1" onClick="value(and); "><b><font size="1">AND</font></b>
	
	
		<input type="radio" value="OR" name="R1" onClick="value(or); "><b><font size="1">
 
Cool, glad to see you attempted it.

change the following:
HTML:
<input type="radio" value="AND" name="R1" onClick="setValue(this); "><b><font size="1">AND</font></b>
<input type="radio" value="OR" name="R1" onClick="setValue(this); "><b><font size="1">


JavaScript:
//Set r1 initially to what the radio button is initially set to, if it is not initially set, in most cases it should be
var r1 = false;
function setValue(obj) {
   r1 = obj.value;
}

Querystring call:

Code:
<input type="button" class="formfield" value="submit" onClick="window.location=self.location.href.split('?')[0] + '?row=' + document.myform.mylist.value + '&value=' + this.form.values.value + '&set=1' + '&r1=' + [!]r1[/!]">

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top