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

How do I combine two pieces of code?

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
0
0
US
My boss wrote this code. It creates
a button and a pulldown. The pulldown sets
a value and the button sends you to fruits.asp.

<form method=&quot;POST&quot; action=&quot;fruits.asp&quot;>
<p align=&quot;left&quot;>
<select name=&quot;AccessType&quot;>
<option value=&quot;A&quot; selected> apple </option>
<option value=&quot;G&quot;>grape</option>
<option value=&quot;C&quot;>cherry</option>
</select>
<input type=&quot;submit&quot; value=&quot;GO&quot; name=&quot;Submit&quot; tabindex=&quot;2&quot;></p>
</form>

When the user reaches fruits.asp, they
immediately go to another page. The code
on fruits.asp looks like this:

Select Case AccessType
Case &quot;A&quot;
response.redirect &quot;apple.asp&quot;
Case &quot;G&quot;
response.redirect &quot;grape.asp&quot;
Case &quot;C&quot;
response.redirect &quot;cherry.asp&quot;
End Select


I have this code, which opens a new window
without all of the normal IE features.

<a href=&quot; onClick=&quot;window.open(' 'myWin',
'width=800, height=600,left=0,top=0');
return false&quot;
>the link text</a>

How do I combine these two concepts, so that we
have his pulldown/button, but the new window opens
with my special characteristics? I am not sure
whether to add my code to the first page or the second
page. I have a feeling that I just need to use &quot;window.open...
...top=0')&quot; and not the whole thing.
 
Hey Steve,

It really depends on what you're trying to do. The Open window script opens a new window over which ever window opened it. So if you want the original fruit selection page to still be available put the window.open on the fruit selection page. If you want a different page under the pop-up then put the window.open on the different page.

Let me know if you need help getting the window Open to work with the Submit button, or even just make it work when a person selects a fruit from the dropdown. It isn't necessary for them to hit submit also, unless there are more options they have to select.





Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Currently, the second page only exists for a brief moment. Its entire purpose is to redirect the user. The user never even sees it. So we do not want it to remain on the screen.

In my experiments, I noticed that once you launch a window with these parameters, every web page that loads in that window has the same parameters. So my initial idea was to put my code on the first page, where it currently says &quot;action =&quot;fruits.asp&quot;>&quot;. I knew that the second page would only appear briefly, but I thought that that would be okay, because the new window's parameters would be set. When I did that I just got an error. I don't know if my idea is bad, or I made a small mistake somewhere.

 
post the code we'll take a look.

Personally I would leave the Fruit selection page in the background and submit to a new window with your properties like this:
Code:
<script type=&quot;text/javascript&quot;>
function openWin() {
window.targetWin = window.open(&quot;&quot;,&quot;targetWin&quot;,&quot;height=800, width=600&quot;);
return true;
}
</script>

<FORM ACTION=&quot;fruit.asp&quot; target=&quot;targetWin&quot; NAME=&quot;test&quot; METHOD=&quot;POST&quot; onsubmit=&quot;return openWin();&quot;>
(code copied/adapted from jemminger)


I'm sure you could even add your
Case fruit selections
into the javascript and save the ASP server work.

let us know what you want.



Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Well, this is my best attempt so far:

<form method=&quot;POST&quot; action=window.open('http:/this/is/my/pages/address.asp','myWin','width=800, height=600,left=0,top=0')>
<p align=&quot;left&quot;>
<select name=&quot;AccessType&quot;>
<option value=&quot;c&quot;> cherries </option>
<option value=&quot;a&quot;>apples</option>
<option value=&quot;g&quot;>grapes</option>
</select>
<input type=&quot;submit&quot; value=&quot;GO&quot; name=&quot;Submit&quot; tabindex=&quot;2&quot;></p>
</form>

It treats &quot;window.open...&quot; as a URL and tries to send the user there! Ugh! I want it to open a new window and then load address.asp [not real page name] into that window. As I said, the second page only appears for a moment. However, I think once I start loading into that window, all of the new pages will have that window's format. That is what I want.
 
<form method=&quot;POST&quot; action=&quot;http:/this/is/my/pages/address.asp&quot; target=&quot;_blank&quot; ..>

then set your browser attributes (width, height etc.) in client side javascript in the onload event of the new page.


-pete
 
You could also try this Steve,
it worked for me.

Code:
<script>
function doSubmit(form)
{
form.action = form.AccessType.value;
window.targetWin = window.open(&quot;&quot;,&quot;tWin&quot;,&quot;height=800, width=600&quot;);
return true;
}
</script>

<form action=&quot;this.htm&quot; name=&quot;fruit&quot; method=&quot;POST&quot; target=&quot;tWin&quot; onSubmit=&quot;return doSubmit(this);&quot;>
<p align=&quot;left&quot;>
<select name=&quot;AccessType&quot; >
<option value=&quot;cherry.asp&quot;> cherries </option>
<option value=&quot;apple.asp&quot;>apples</option>
<option value=&quot;grape.asp&quot;>grapes</option>
</select>
<input type=&quot;submit&quot; value=&quot;GO&quot; name=&quot;Submit&quot; tabindex=&quot;2&quot;></p>
</form>

it cuts out the ASP page. submits the form to the page you selected. I hope it helps.


Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Palbano, I implemented your suggestion and it did improve the situation. My code for the form method is now:

<form method=&quot;POST&quot; action=address.asp target=&quot;_blank&quot; onload=&quot;width=800, height=600,left=0,top=0&quot;>

That DOES open a new browser window and load the new page into it. However, it does NOT give the page custom properties. Obviously, my goal to to create a page without a menu,toolbars,etc.

tlhawkins, I am testing your solution now.
 
Hi Steve,

I am not sure if you need a new window to be opened, if you do, let me know and I will try to help

ciau
Faadiel

<SCRIPT LANGUAGE=&quot;JavaScript&quot; TYPE=&quot;text/javascript&quot;>
<!--
function funcChangeAction(strValue){
if(strValue==&quot;A&quot;){
document.fruit.action = &quot;apple.asp&quot;;
}
if(strValue==&quot;G&quot;){
document.fruit.action = &quot;grape.asp&quot;;
}
if(strValue==&quot;C&quot;){
document.fruit.action = &quot;cherry.asp&quot;;
}
}
//-->
</SCRIPT>
<form method=&quot;POST&quot; name=&quot;fruit&quot; action=&quot;apple.asp&quot;>
<p align=&quot;left&quot;>
<select name=&quot;AccessType&quot; onchange=&quot;funcChangeAction(this.value)&quot;>
<option value=&quot;A&quot; selected> apple </option>
<option value=&quot;G&quot;>grape</option>
<option value=&quot;C&quot;>cherry</option>
</select>
<input type=&quot;submit&quot; value=&quot;GO&quot; name=&quot;Submit&quot; tabindex=&quot;2&quot;></p>
</form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top