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

Query string passing in frames...

Status
Not open for further replies.

jstar7

Programmer
Dec 17, 2002
61
GB
I have a page with a floating frame on it...(I know its a bad idea). I want to pass a query string from it to an ASP page which will then be displayed in the frame. I tried this but it didnt work...

<code>
function jsClick(inVar){
parent.iframe1.location = &quot;index2.asp?jsVar=&quot; + inVar;
}
</code>

Any ideas?
 
if the new page will be displayed in the same frame, just use:

<%
document.redirect &quot;newPage.asp?varName=&quot; & varValue
%>

if you need to use client-side code (javascript)

<script>
function jsClick(inVar){
document.location = &quot;index2.asp?jsVar=&quot; + inVar;
}
</script>


-----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
yeah i tried that but it didnt work. Is it maybe something to do with how it is requested? I used...

<%
imgstring = request.querystring(&quot;jsVar&quot;)
%>

...which didnt work.
 
can you post the code you are using to create the querystring? You are getting the result in the correct manner.... -----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
I used &quot;jemima&quot; as a test string to see if it would work.
This function is just called from an onClick event.


function arrstr() {
imgstring = &quot;jemima&quot;;
jsClick(imgstring);
}

 
I'm sorry, I actually need to see the whole page.... -----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
ok then...(sorry for it being large)

<html>
<title>[star::seven::doodle]</title>

<style type=&quot;text/css&quot;>BODY
.box {
BORDER-RIGHT: #cecece 1px solid; BORDER-TOP: #cecece 1px solid; FONT-SIZE: 12px;
BORDER-LEFT: #cecece 1px solid; COLOR: #000000; BORDER-BOTTOM: #cecece 1px solid; FONT-FAMILY: Verdana
}
.box2 {
BORDER-RIGHT: #585858 1px solid; BORDER-TOP: #585858 1px solid; FONT-SIZE: 10px; BORDER-LEFT: #585858 1px solid; COLOR: #585858; BORDER-BOTTOM: #585858 1px solid; FONT-FAMILY: Verdana
}
</style>
<script language=&quot;JavaScript&quot;>
<!--
function refresh() {
parent.location.href = parent.location.href;
}
-->
</script>
<head>



<script type=&quot;text/javascript&quot;>


var imgarray = new Array(1500);
var pos=0;
var imgstring;
var inVar;

function init() {
if (!document.getElementById) return
var imgOriginSrc;
var imgTemp = new Array();
var imgarr = document.getElementsByTagName('img');
for (var i = 0; i < imgarr.length; i++) {
if (imgarr.getAttribute('hsrc')) {
imgTemp = new Image();
imgTemp.src = imgarr.getAttribute('hsrc');
imgarr.onmouseover = function() {
imgOriginSrc = this.getAttribute('src');
this.setAttribute('src',this.getAttribute('hsrc'))
}
}
}
}
onload=init;


function matrix(pos) {
imgarray[pos] = 1;
}

function update(pos) {
imgarray[pos] = 2;

}

function outputmat() {
for (y=1; y<imgarray.length; y++){
document.write (imgarray[y]);
}
}

function arrstr() {
imgstring = &quot;jemima&quot; ;
jsClick(imgstring);
}

function jsClick(inVar){
document.location = &quot;index2.asp?jsVar=&quot; + inVar;
}

</script>

</head>


<body background=&quot;loading.jpg&quot;>

<table border=&quot;0&quot;>
<tr>
<td class=&quot;box2&quot;>
<script language=&quot;javascript1.2&quot;>
<!--
for (x=0; x<30; x++){

for (i=0; i<50; i++){
pos=pos+1;
document.write (&quot;<a href='#' onMouseover=(update(&quot;+pos+&quot;))><IMG src='2.jpg' hsrc='1.jpg' class=box border=0 name=img1></a>&quot;);
matrix(pos);
}
document.write (&quot;<BR>&quot;);}
-->
</script>
</td>
</tr>
<tr>
<td>
<img src=&quot;refresh.jpg&quot; class=&quot;box2&quot; onClick=&quot;refresh()&quot;>
<img src=&quot;subgall.jpg&quot; class=&quot;box2&quot; WIDTH=&quot;155&quot; HEIGHT=&quot;30&quot; onClick=&quot;arrstr()&quot;>

</td>
</tr>
</table>
</body>
</html>
 
These look alright and they should work....

function arrstr() {
imgstring = &quot;jemima&quot; ;
jsClick(imgstring);
}

function jsClick(inVar){
document.location = &quot;index2.asp?jsVar=&quot; + inVar;
}

I would try several steps:

First just try the straight URL in one function:
function arrstr(inVar){
document.location = &quot;index2.asp?jsVar=jemima&quot;;
}

Then make sure you receive the value on index2. If not, I'd like to see your code for index2.... -----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
ok...tried that...but again nothin arrived on index2.asp...here is the code. I know that nothing arrives as I have set the database to not allow a blank entry. So each time I submit it, there will be an error along the lines of field name cannot be of zero length.

<html>
<head>
<title>[star::seven::doodle]</title>
</head>

<body>
<%
Flag = request.form(&quot;Flag&quot;)
If IsEmpty(Flag) or Flag = &quot;&quot; then
%>
<br><br>
<table border=&quot;0&quot;>
<tr>
<td align=&quot;right&quot;>
<font size=&quot;1&quot; color=&quot;#585858&quot; face=&quot;Verdana&quot;><b>Doodle Name:</b>
</td>
<td><form action=&quot;index2.asp&quot; method=&quot;post&quot; id=&quot;form1&quot; name=&quot;form1&quot;>
<input type=&quot;text&quot; name=&quot;DoodleName&quot; size=&quot;35&quot; class=&quot;box&quot; bgcolor=&quot;#cecece&quot;>
</td>
</tr>
<tr>
<td align=&quot;right&quot;>
<font size=&quot;1&quot; color=&quot;#585858&quot; face=&quot;Verdana&quot;><b>Created By:</b>
</td>
<td>
<input type=&quot;text&quot; name=&quot;CreatedBy&quot; size=&quot;35&quot; class=&quot;box&quot;>
</td>
</tr>
<tr>
<td valign=&quot;top&quot; align=&quot;right&quot; width=&quot;240&quot;>
<font size=&quot;1&quot; color=&quot;#585858&quot; face=&quot;Verdana&quot;><b>What you should be doing:</b>
</td>
<td>
<textarea name=&quot;ShouldBe&quot; cols=&quot;34&quot; rows=&quot;4&quot; class=&quot;box&quot;></textarea>
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td align=&quot;right&quot;>
<input type=&quot;image&quot; src=&quot;submit.jpg&quot; value=&quot;Submit&quot; class=&quot;box&quot; id=&quot;submit1&quot; name=&quot;submit1&quot;>
<input type=&quot;hidden&quot; name=&quot;Flag&quot; value=&quot;1&quot;>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
End If
If Flag = 1 then
If IsEmpty(request.form(&quot;DoodleName&quot;)) or request.form(&quot;DoodleName&quot;)=&quot;&quot; then
response.write &quot;<table><tr><td width=400 align=right>&quot;
response.write &quot;<font face='verdana' size=1 color='#585858'><br><br><br>&quot;
response.write &quot;<p><br><b>You must enter a Doodle name.</b></font>&quot;
response.write &quot;<form>&quot;
response.write &quot;<input type='button' value='Retry' class=box onclick=history.back()>&quot;
response.write &quot;</form>&quot;
response.end
Else
DoodleName = request.form(&quot;DoodleName&quot;)
End If

If IsEmpty(request.form(&quot;CreatedBy&quot;)) or request.form(&quot;CreatedBy&quot;)=&quot;&quot; then
response.write &quot;<table><tr><td width=400 align=right>&quot;
response.write &quot;<font face='verdana' size=1 color='#585858'><br><br><br>&quot;
response.write &quot;<p><br><b>You must enter a Created By name.</b></font>&quot;
response.write &quot;<form>&quot;
response.write &quot;<input type='button' value='Retry' class=box onclick=history.back()>&quot;
response.write &quot;</form>&quot;
response.end
Else
CreatedBy = request.form(&quot;CreatedBy&quot;)
End If

If IsEmpty(request.form(&quot;ShouldBe&quot;)) or request.form(&quot;ShouldBe&quot;)=&quot;&quot; then
response.write &quot;<table><tr><td width=400 align=right>&quot;
response.write &quot;<font face='verdana' size=1 color='#585858'><br><br><br>&quot;
response.write &quot;<p><br><b>You must say what you should be doing.</b>&quot;
response.write &quot;</font><form>&quot;
response.write &quot;<input type='button' value='Retry' class=box onclick=history.go(-1)>&quot;
response.write &quot;</form>&quot;
response.end
Else
ShouldBe = request.form(&quot;ShouldBe&quot;)
End If

Flag = request.form(&quot;Flag&quot;)
%>
<table border=&quot;0&quot;>
<tr>
<td width=&quot;100&quot;>&nbsp;</td>
<td width=&quot;220&quot;>
<font face=&quot;verdana&quot; size=&quot;1&quot; color=&quot;#585858&quot;><b>
<br>If you are happy with your post below then click Submit. If not,
click Retry.<br><br>
</td></tr>


<tr><td align=&quot;right&quot;><font face=&quot;verdana&quot; size=&quot;1&quot; color=&quot;#585858&quot;><b>Doodle Name:</b></td><td><font face=&quot;verdana&quot; size=&quot;1&quot; color=&quot;#585858&quot;> <%= DoodleName %></td></tr>
<tr><td align=&quot;right&quot;><font face=&quot;verdana&quot; size=&quot;1&quot; color=&quot;#585858&quot;><b>Created By: </b></td><td><font face=&quot;verdana&quot; size=&quot;1&quot; color=&quot;#585858&quot;> <%= CreatedBy %></td></tr>
<tr><td align=&quot;right&quot;><font face=&quot;verdana&quot; size=&quot;1&quot; color=&quot;#585858&quot;><b>Should be doing: </b></td><td><font face=&quot;verdana&quot; size=&quot;1&quot; color=&quot;#585858&quot;> <%= ShouldBe %></td></tr>
<tr><td></td><td><br>
<form action=&quot;index2.asp&quot; method=&quot;post&quot; id=&quot;form2&quot; name=&quot;form2&quot;>
<input type=&quot;hidden&quot; name=&quot;DoodleName&quot; value=&quot;<%= DoodleName %>&quot; class=&quot;box&quot;>
<input type=&quot;hidden&quot; name=&quot;CreatedBy&quot; value=&quot;<%= CreatedBy %>&quot; class=&quot;box&quot;>
<input type=&quot;hidden&quot; name=&quot;ShouldBe&quot; value=&quot;<%= ShouldBe %>&quot; class=&quot;box&quot;>
<input type=&quot;hidden&quot; name=&quot;Flag&quot; value=&quot;2&quot;>
<input type=&quot;submit&quot; value=&quot;Yes, Submit it!&quot; class=&quot;box&quot; id=&quot;submit2&quot; name=&quot;submit2&quot;>&nbsp;
<input type=&quot;button&quot; value=&quot;Retry&quot; onClick=&quot;history.go(-1)&quot; class=&quot;box&quot; id=&quot;button1&quot; name=&quot;button1&quot;>
</form></font>
</td>
</tr>
</table>
<%
End If
If Flag = 2 then

Today = Now()
DoodleName = request.form(&quot;DoodleName&quot;)
CreatedBy = request.form(&quot;CreatedBy&quot;)
ShouldBe = request.form(&quot;ShouldBe&quot;)
imgstring = request.querystring(&quot;jsVar&quot;)

set conn = server.createobject(&quot;adodb.connection&quot;)
conn.Mode = 3
conn.Open &quot;guestbook&quot;

SQLstmt = &quot;INSERT INTO Doodlepad (DoodleName,CreatedBy,ShouldBe,DoodleNum)&quot;
SQLstmt = SQLstmt & &quot; VALUES (&quot;
SQLstmt = SQLstmt & &quot;'&quot; & DoodleName & &quot;',&quot;
SQLstmt = SQLstmt & &quot;'&quot; & CreatedBy & &quot;',&quot;
SQLstmt = SQLstmt & &quot;'&quot; & ShouldBe & &quot;',&quot;
SQLstmt = SQLstmt & &quot;'&quot; & imgstring & &quot;'&quot;
SQLstmt = SQLstmt & &quot;)&quot;

Set RS = conn.execute(SQLstmt)
If err.number>0 then
response.write &quot;VBScript Errors Occured:&quot; & &quot;<P>&quot;
response.write &quot;Error Number=&quot; & err.number & &quot;<P>&quot;
response.write &quot;Error Descr.=&quot; & err.description & &quot;<P>&quot;
response.write &quot;Help Context=&quot; & err.helpcontext & &quot;<P>&quot;
response.write &quot;Help Path=&quot; & err.helppath & &quot;<P>&quot;
response.write &quot;Native Error=&quot; & err.nativeerror & &quot;<P>&quot;
response.write &quot;Source=&quot; & err.source & &quot;<P>&quot;
response.write &quot;SQLState=&quot; & err.sqlstate & &quot;<P>&quot;
end if
IF conn.errors.count> 0 then
response.write &quot;Database Errors Occured&quot; & &quot;<P>&quot;
response.write SQLstmt & &quot;<P>&quot;
for counter= 0 to conn.errors.count
response.write &quot;Error #&quot; & conn.errors(counter).number & &quot;<P>&quot;
response.write &quot;Error desc. -> &quot; & conn.errors(counter).description & &quot;<P>&quot;
next
else
response.write &quot;<table><tr><td width=400 align=center>&quot;
response.write &quot;<font face='verdana' size=1 color='#585858'><br><br><br>&quot;
response.write &quot;<p><br><b>Cheers! Your entry has been added.<br>Now get back to work!!&quot;
response.write &quot;<br><a href='index2.asp'>Again?</a>&quot;
end if
Conn.Close
Set conn = nothing
End If
%>

</body>
</html>
 
in the begining of index2.asp, put this code:

%>
<script>
myVar = &quot;<%=request(&quot;jsVar&quot;)%>&quot;
if (myVar != &quot;&quot;){
alert(myVar)
}
</script>
<%


This will show us that the variable is being passed.... -----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
yeah the alert showed with jemima which is something eh?!
 
It is quite a bit, we know that the error is on index2.asp. I'm a little confused about index2.asp, you use &quot;request.form&quot; quite a bit on it, but you are not calling it from a form. What am I missing? -----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
I dunno really...ive always used the form method and this page is a kind of amalgamation of other ones i have used before. NB. This page works fine if I take out the imgstring part and just use the other 3 variables. This is just an added part that I wanted to put into the same record in the database. I thought it would be easier to do it this way rather than get caught up with getting the right record id and stuff.
 
Try changing the line:

imgstring = request.querystring(&quot;jsVar&quot;)

to

imgstring = request(&quot;jsVar&quot;)

and (again) put this code right after it....

%>
<script>
myVar = &quot;<%=imgstring%>&quot;
if (myVar != &quot;&quot;){
alert(myVar)
}
</script>
<%
-----------------------------------------------------------------
&quot;C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.&quot;
- Bjarne Stroustrup

mikewolf@tst-us.com
 
Nah that didnt work either, just returned a semicolon.
 
That doesn't make any sense. You can pull the variable correctly at the top of the page, but not later on? You should be able to call it throughout your page.

Since we got the variable's value at the beginning of the page, why don't you load it into a local variable there and use it later on.

Or try this:

SQLstmt = &quot;INSERT INTO Doodlepad (DoodleName,CreatedBy,ShouldBe,DoodleNum)&quot;
SQLstmt = SQLstmt & &quot; VALUES (&quot;
SQLstmt = SQLstmt & &quot;'&quot; & DoodleName & &quot;',&quot;
SQLstmt = SQLstmt & &quot;'&quot; & CreatedBy & &quot;',&quot;
SQLstmt = SQLstmt & &quot;'&quot; & ShouldBe & &quot;',&quot;
SQLstmt = SQLstmt & &quot;'&quot; & request(&quot;jsVar&quot;) & &quot;'&quot;
SQLstmt = SQLstmt & &quot;)&quot;
-----------------------------------------------------------------
&quot;The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.&quot;
- unknown

mikewolf@tst-us.com
 
Yeah I loaded into a local variable and it went fine. I dont get it either because it should have worked before, but thanks for your help. It is greatly appreciated.
Cheers,
J
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top