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

Close button in asp page

Status
Not open for further replies.

sandra45

Technical User
Apr 3, 2003
72
ID
Hi, I have code running at client and server in one asp page. After the user fills in data in the form, the asp page will call itself and response.write "thank you". How to append a close button below the line "thank you" and close the window? As you know the response command is server object, while window is browser object, how to combine them both and the location of the command button in the asp page? Thank you.

Regards,
Sandra
 
hi Sandra,
You can write Javascript code in asp tags :
Response.write &quot;<script></script>&quot;
Response.write &quot;<input type=button name=B1>&quot;

for your problem:u have to do all this
1) First u can create a <SPAN id=myspan name=span1></SPAN> tag where u want button and give it to id or some name.
2) Add this code below ur Response.write &quot;thank u&quot;
code:-
Response.write(&quot;<script>myspan.innerHTML='<input type=button name=B1 value=Close onclick=window.close();'</script>&quot;)
OR
Response.write(&quot;<script>formname.span1.innerHTML='<input type=button name=B1 value=Close onclick=window.close();'</script>&quot;)

I think this works.
Knowledge is waste until it is unshared.

 
Hi Bhoge, thanks for your info. I'm not clear with your point number 1) First u can create a <SPAN id=myspan name=span1></SPAN> tag where u want button and give it to id or some name.

Do I need to include the function to close window here or? Can you please elaborate more on this? Thanks.

One more thing, I have error message when close the connection string to MySQL, what should I do with this? If I let it open, everything runs well, is there a problem when other person wants to insert new data to MySQL? Thanks.

Regards,
Sandra
 
hi sandra,
Span tag used where we have to make logical place for some html tag or text.same u can create logical place for your button prior to actully creating it and then use the response.write statement as i told u before in script code we use span for placing the button thats for accessing the particular span tag we have to give it id .u can learn more about it from document object model.
no extra function is required.
Response.write(&quot;<script>myspan.innerHTML='<input type=button name=B1 value=Close onclick=window.close();'</script>&quot;)
this statement can create button as well as addthe function for close the window.
for ur MYSQL prob i have not sufficient knowledge to solve this prob.
Knowledge is waste until it is unshared.
 
Thanks Bhoge, I'll come back to you if I encounter a problem.

I have another problem at this moment. I have to use java script for client script (due to browser compatibility) and leave vbscript for server script. I have several radio buttons in one question, so I'm using java script to create a function AllRadioButtons() to loop through these buttons and check if at least one is checked, if yes, then it will return true, else return false. Then I create another function that relates to submit button to call that AllRadioButtons function. This function will check if AllRadioButtons is false, then alert message will be thrown, if true, then it should process the asp form action at the server side, i.e. collect data submitted by user and insert data to the database. However, I can't have any reaction from my Submit1_Onclick() function. What is wrong? Here is the code:
<!-- Client-side form validation code -->
<script Language=&quot;JavaScript&quot;>
function Submit1_Onclick()
{
if(AllRadioButtons() == true)
{
document.frmFB.submit;
}
else
{
alert(&quot;Please make a selection to the question.&quot;);
}
}

function AllRadioButtons()
{
var checkAllRadioButtons;
for(i=0;i<document.frmFB.frequency.length;i++)
{
if(document.frmFB.frequency.checked == true)
{
checkAllRadioButtons = true;
return true;
}
else
{
checkAllRadioButtons = false;
return false;
}
}
}
</script>

'Here comes server side script in VBScript language
.
.
.
<FORM action=blabla.asp method=post name=frmFB id=frmFB></TABLE>
.
.
.
<INPUT type=button id=Submit1 name=Submit1 value=&quot;Send Feedback&quot;></p>
.
.
.

Thanks a lot, I'm very frustrated with this one.

Regards,
Sandra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top