ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 4th, 2003, 09:34 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Cool want to open a new window on button click!-jscript or javasript

Hi all...

i am was unable to work on asp to word........it was sendign me shivers to even try and test it. but thanks to this forum... i am almost nearing all my main tasks in my small assignment on asp website devlopment.

my story of student-teacher must be clear to all. I am now able to select a student's story and open it in a word doc. the teacher then corrects the story, highlight in colors the comments, strikethrough. In fact all the priveleges i wanted as an editor can be achieved. This word doc gets opened in a new window ... the best part

now i have 2 buttons on teacher window. One which would open a separate window to a word doc and another i want it to open in another asp page. since i have given -> target="new_window"
in form tag so right now both the buttons open to a new window of word file:
<form action="word_create.asp" target="new_window">

how can i make the other button open another window. do i have to use on_click() event and use jscript? vbscript works only 4 IE so i have to use jscript????

I dont want to use javascript.... as i have to run the website on a machine which is MS based (or is this irrelevent?)

can anyone help me how to use the on_click event to open another window?
here is my code..
<html>
<head><title>Create a word document</title></head>
<body>
<center>
<font color="#800080" size="4"><b>
Create a word document</b></font>
</center>
<p>
<center>
</p>
<table>
<form action="word_create.asp" target="new_window">
<%
Dim strSelectValues
Dim strSelectedText1
Dim strSelectedText2
DIM RSA
DIM QUERY1

strSelectValues = Trim(Request.form("RR"))
'FOR DEBUG ONLY
'Response.Write "ds-->" & strSelectValues & "<--<hr>"

strSelectedText1 = Split(strSelectValues, ";")(0)
strSelectedText2 = Split(strSelectValues, ";")(1)
'FOR DEBUG ONLY
'Response.Write "one-->" & strSelectedText1 & "<--<hr>"
'Response.Write "two-->" & strSelectedText2 & "<--<hr>"

Set RSA = Server.CreateObject("ADODB.Recordset")
QUERY1 = "select story_original from student_content where student_id = '"&strSelectedText2&"' and story_id = '"&strSelectedText1&"'"
rsa.open query1, "dsn=school"
response.write "mm"
%>

<tr>
<td><font color="#000080" size="3"><b>Name:</b></font> </td>
<td><input type="text" name="Name" size="50" maxlength="100"></td>
</tr>
<tr>
<td><font color="#000080" size="3"><b>Email:</b></font> </td>
<td><input type="text" name="Email" size="50" maxlength="100"></td>
</tr>
<tr><td>
<font color="#000080" size="3"><b>
Comments:</b></font> </td><td>
<textarea cols="50" rows="10" name="comments" ><%=RSA.Fields.item("story_original").value %></textarea></td>
</tr>
</table>
</center>
<p align="center">
<input type="submit" value="Check Story">
<input type="submit" value="Grade Student">
</form><p align="left">&nbsp;</p>
</body>
</html>

thanks all ..........................

Reply With Quote
  #2  
Old September 4th, 2003, 09:57 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Why do you have *two* submit buttons?

You realize that both, submit buttons, will send your <form>...</form>'s data to word_create.asp regardless of which one is clicked!

You realize that right???

Anyway...what I think you need/want is this(and your question should've been):

"How can I have 2 buttons that submit the form to 2 different places"


In order to do that, you'll need to *S I M U L A T E* two submit buttons but in fact, the're going to be two regular buttons.

The key thing to understand here is that you'll create two *regular* buttons with an onclick attribute.

Both onclick attributes will/can call two different javascript function!
Why javascript?
Cause that's what I use...and since I usually want my code to work in both major browsers then I use javascript for my client-side scripting.
If I was creating an intranet and that I knew for *sure* that everyone was using Internet Explorer then, I'd probably use VBscript as my client-side scripting...but knowing myself I'd still use javascript out of habit...

Now create two regular buttons like I said
<input type="button" name="btn1" value="click 1" onclick="javascript:FunctionOne();">
<input type="button" name="btn2" value="click 2" onclick="javascript:FunctionTwo();">

Now in the <head>...</head> portion of your code, simply create these two javascript functions like:

<head>
<script language="javascript">
function FunctionOne()
{
alert("you have clicked the button click 1");
}

function FunctionTwo()
{
alert("you have clicked the button click 2");
}
</script>
</head>

All you need to do now is remplace that silly alert message I've given as an example and write your own code that will submit the <form>...</form>


Hope this helps!
Sincerely

Vlince

Last edited by Vlince : September 4th, 2003 at 10:00 AM.

Reply With Quote
  #3  
Old September 4th, 2003, 10:01 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Lightbulb

yes i wanted exactly what u explained ... let me now try this thing!


thanks!

Reply With Quote
  #4  
Old September 4th, 2003, 10:13 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Lightbulb

hi vlince...

i had a quick question....rather than having 2 buttons opening into 2 different pages ... i want one button to open the word file and the other one to open a fresh page on the same one where i had 2 buttons?

can i achieve this or do i still need to have 2 buttons??
i hope i am clear?

Reply With Quote
  #5  
Old September 4th, 2003, 10:35 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Well...aspuser25!

Things won't automagically happen you know

you say you want:
i want one button to open the word file and the other one to open a fresh page

but then you say:
can i achieve this or do i still need to have 2 buttons

Well of course you can acheive this and of course you'll need two buttons, otherwise how can you possibly do it?

well there is a way but...

Ok back to business.
Now you want one button to open a new file, ok great, create a *regular* button with an onclick attribute calling a javascript function that will open a new window.

then leave your other button a submit button, DO NOT make it a regular button, leave it as a *submit* button

That's the one that will refresh the page like you said...

Hope this helps!
Sincerely

Vlince

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > want to open a new window on button click!-jscript or javasript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway