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

ElementByID from one page to another

Status
Not open for further replies.

eldred75

Programmer
Sep 27, 2006
5
ZA
I have a radiobutton value Ascending from a pop-up screen to my that I can parse back to mainscreen using elementByID

1. when I hit the done button I call this object which is on my little pop-up screen:


function addSelectedItemsToOrderAsc()
{
var b = document.getElementById('radioSortBy') --this is my id='"radioSortBy'"
b.checked=true;
self.opener.addToParentListOrderByAsc(b);
window.close();
}

--from popup screen,


But the problem is from gettting my value from the popup box screen to my main screen.


2. The radioSortBy' element should then be transfered from addSelectedItemsToOrderAsc to "addToParentListOrderByAsc" functions

The addToParentListOrderByAsc looks like so, this function resides on my destination page, or main page


var OrderSourceAsc = document.getElementById('radioSortBy');

//OrderByList comes from my pop-up page

function addToParentListOrderByAsc(sourceList6) // to my destination page
{
var orderAscDestList = document.getElementById('sortByAsc'); //this is my hidden field on my mainInput Page
for(var countTwo = orderAscDestList.options.length - 1; countTwo >= 0; countTwo--) { // I AM GETTING AN ERROR objects.length is null or not an object because its not parsing my 'radioSortBy' value in ?


orderAscDestList.options[countTwo] = null;
}
for(var i = 0; i < sourceList6.options.length; i++) {
if (sourceList6.options != null)
orderAscDestList.options = new Option(sourceList6.options.text, sourceList6.options.value );
}
}

// Marks all the items as selected for the submit button.

function selectListAsc(sourceList6) {
var sourceList6 = document.getElementById('sortByAsc');
for(var i = 0; i < sourceList6.options.length; i++) {
if (sourceList6.options != null)
sourceList6.options.selected = true;
}
return true;
}

Can someone advise what I am doing wrong, still a newbie, thankyou.
 
Hi BillyRayPreachersSon

No, I don't , developing on localhost. What I am trying to say is I have a radiobutton on one window that has a default value of 1, I want to parse this fault value from the pop up page to my parent/ main page

Below is my source code for my pop-up page and my main page

////some code from my parent page

<script language="javascript" type="text/javascript"">
function addSelectedItemsToOrderAsc(b)
{
var b = document.getElementById('radioSortBy')//this is my element <input type="radio" name="radioSortBy" value="1" id="radioSortBy" checked>Ascending<br>
b.checked=true;
self.opener.addToParentListOrderByAsc(b); //parse this variable b onto my parent page

window.close();
}
</script>
</head>

..some html code here
<input type="radio" name="radioSortBy" value="1" id="radioSortBy" checked>Ascending<br>
<input type="radio" name="radioSortBy" value="2" id="radioSortBy">Descending

..some html code here
<input type="submit" name="done" value="Done" onClick = "javascript:addSelectedItemsToOrderBy(),addSelectedItemsToOrderAsc();">
</form>
<!-- Page content ends here -->


//this is my parent page

<script language="javascript" type="text/javascript"">

<!-----------------------order by---------->
<!-- Begin

var OrderSourceAsc = document.getElementById('radioSortBy');//this is elementID from my pop-up page

function addToParentListOrderByAsc(sourceList6)
{
var orderAscDestList = document.getElementById('sortByAsc');
for(var countTwo = orderAscDestList.options.length - 1; countTwo >= 0; countTwo--) {
orderAscDestList.options[countTwo] = null;
}
for(var i = 0; i < sourceList6.options.length; i++) {
if (sourceList6.options != null)
orderAscDestList.options = new Option(sourceList6.options.text, sourceList6.options.value );
}
}
// Marks all the items as selected for the submit button.
function selectListAsc(sourceList6) {
var sourceList6 = document.getElementById('sortByAsc');

for(var i = 0; i < sourceList6.options.length; i++) {
if (sourceList6.options != null)
sourceList6.options.selected = true;
}
return true;
}

<!-----------end of orderby

<html>
<input type="text" name="sortByAsc" id="sortByAsc">
</html>

I want to detault value being 1 into this form object.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top