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

pass value to another page w\o submit 3

Status
Not open for further replies.

skibascott

IS-IT--Management
Mar 18, 2004
82
US
I have an intranet page with a select box that is populated with records from a database using asp. When an item is selected the values associated with the selected item are displayed on the page with javascript. On the same page I also have an iframe that I would like to load documents that are associated with the selected item. I need to pass a value to the document in the iframe in order to specify what to display in the iframe. I can do this with a form and submit.
But, I would like to avoid the form and submit if possible because when the submit button is clicked the main page reloads and I lose the selected item and the values displayed with that item.
Is it at all possible to pass this value to another page(the asp page loaded into the iframe) without the main page refreshing?
 
Use Javascript to add the parameters to the link with the URL of the page going into the iframe, and parse that information from that page.

Lee
 
Sure. Use the get/querystring method (not sure how it works in ASP, maybe Request.Querystring?). If you want to stay client-side, see faq216-5442.
Code:
<html>
<head>
<script type="text/javascript">
<!--

function loadPage(f)
{
  var url = "pageiniframe.asp?index=";
  var index = f.elements['s'].options[f.elements['s'].selectedIndex].value;
  url += index;
  document.getElementById("i").src = url;
}

// -->
</script>
</head>
<body>
<form name="f" id="s">
<select name="s" id="s">
<option value="1" selected="selected">Record 1</option>
<option value="2">Record 2</option>
<option value="3">Record 3</option>
</select>
<input type="button" value="Display" onclick="loadPage(this.form);">
</form>
<br /><br />
<iframe id="i" name="i" src="about:blank">No page loaded</iframe>
</body>
</html>

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Thank you both. This is exactly what I was looking for and it works perfect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top