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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble getting value from checkbox in Iframe

Status
Not open for further replies.

N3XuS

Programmer
Mar 1, 2002
339
BE
I have 3 inline editors on one page, and I'm trying to prevent that they can be submitted when they're in source-mode. In the source of the editor is a checkbox
Code:
<input class="checkbox"  type="checkbox" name="switchMode" id="switchMode" onclick="setEditMode(switchMode)">
The source of all 3 iframes is the same. they're called richedit, richedit2 and richedit3.
Now when someone tries to submit I have to check if the checkbox is true or false.
I can get as far as window.document.all.richedit.document, this still returns an object. When I trye to put window.document.all.richedit.document.getElementById("switchMode") it already is null =( Anyone know what i'm doing wrong here ?

ty :)
 
parent.frames.IFRAMENAME.window.document???

Known is handfull, Unknown is worldfull
 
[tt]>onclick="setEditMode(switchMode)"
Just a guess.
onclick="setEditMode([red]'[/red]switchMode[red]'[/red])"[/tt]
 
vbkris:
i can reach the frame since window.document.all.richedit.document returns [object], the weird thing is once I get that I can't seem to get anything on id ... I need to get the value from the iframe into the main document with a function that's in the main document.

tsuji: that part works it switches the editor to HTML and back. I could ofcourse use it to set a field on the parent, but seeing this editor is used on a lot of pages, I really don't wanna alter'm all. Just wanted to make changes in my js file .

thx guys :)
 
thats why i asked u to use parent.frames.IFRAMENAME.window.document.etElementById

Known is handfull, Unknown is worldfull
 
>that part works it switches the editor to HTML and back
So you are saying some global variable is named switchMode? otherwise, what would switchMode be perceived by the function? an "undefined"?!
 
A global variable in the iframe prolly then :p I highly doubt I can access it from the parent frame.
 
The checkbox is named switchMode , the function has nothing to do with it :p I just need to be able to address the checkbox in the iframe =s I can get the text out of the iframe using window.document.all.richedit.docHtml
which would be great except there's not a single thing called docHtml on the page ... inline editors drive me nuts. ..
 
lol get try gettin this ... when I place a <form tag around the checkbox it even seizes to find the function ... what the f... has that to do with anything. man javascript is messed up
 
solved it the dirty way ...
I put 2 functions in my main document
Code:
var sF1 = false;
var sF2 = false;
var sF3 = false;
var indsF = 0;

function getI() {
	indsF++;
	return indsF;
}

function setS(v,f) {
	if (f == 1){
	sF1 = v.checked;
	}
	else if (f == 2) {
		sF2= v.checked;
	}
	else if (f == 3) {
		sF3= v.checked;
	}
}


I put
Code:
var fieldN = parent.getI();
in the onload of the iframe so it knows from itself what # iframe it is.

And changed the checkbox to
Code:
<input class="checkbox"  type="checkbox" name="switchMode"  onclick="setEditMode(switchMode);parent.setS(switchMode,fieldN);" >

so the chekbox calls a function in the parent to set the correct variable the same as the checkbox ...

it's reversed working ... but still not too much to change in all the files, just need to add the 2 functions to my js and see it checks the 3 variables that have been set by the checkboxes...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top