473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ASP and JavaScript (Passing parameter)

31
Hello,

I have a form includes one text box named "Date", one Submit botton named " Add Item" which will submit the form and open other form.

there is onemore button named " Add Mileage" which by pushing that, I would like to check if the text box named " Date" is empty or not and in both case will open other window and depends if the text box is empty or not, shows different messages in new window open up.

Please please please let me know if you have any solution.

Best Regards,
Faranak
Apr 2 '08 #1
6 1455
jeffstl
432 Expert 256MB
Hello,

I have a form includes one text box named "Date", one Submit botton named " Add Item" which will submit the form and open other form.

there is onemore button named " Add Mileage" which by pushing that, I would like to check if the text box named " Date" is empty or not and in both case will open other window and depends if the text box is empty or not, shows different messages in new window open up.

Please please please let me know if you have any solution.

Best Regards,
Faranak

If you are going to submit the form either way and open a new window either way, you probably one need 1 button right? If you are talking about alert boxes like a validation of a form before submission, then yes you will need to use javascript or client side vbscript.

A perfect example of this can be found here
http://www.w3schools.com/js/js_form_validation.asp

If you are going to submit the form though you can just use ASP to check the value

Expand|Select|Wrap|Line Numbers
  1. dim UserDate
  2. UserDate = request.form("txtDate")
  3. if UserDate = "" then
  4.      'determine message string
  5. else
  6.      'they entered the date
  7. end if
  8.  
Apr 2 '08 #2
F159753
31
Thanks for your reponse, but It is not clear to me yet. Here is my code:



<form name="Formd" action="ContractorExpenseAddItem.asp" method="post" >

<input name="WeekEndingDate" ID="WeekEndingDate" type="text">


<td colspan="1" valign="top"><span class="text"><input type="submit" value="Add Item >"> </span></td>


<td colspan="1" valign="top" width="200"><input type="button" onClick=window.open('ContractorExpenseAddMileage.a sp?IID=<%=A%>','AddMileageWindow','width=600,heigh t=250,toolbar=yes,location=yes,directories=yes,sta tus=yes,scrollbars=yes,copyhistory=yes,resizable=y es') value="Add Mileage >"></td>

</form>

As you see, by Submitting "Add Item" in form action I am submitting the form and opening other form.
My problem is with other button named " Add Mileage" when I click on the button I want to validate the text box first then open other window so basically my form is not submitting so I can't request.form the text box value!!!!!

What should I do? :(
Apr 2 '08 #3
jeffstl
432 Expert 256MB
Thanks for your reponse, but It is not clear to me yet. Here is my code:



<form name="Formd" action="ContractorExpenseAddItem.asp" method="post" >

<input name="WeekEndingDate" ID="WeekEndingDate" type="text">


<td colspan="1" valign="top"><span class="text"><input type="submit" value="Add Item >"> </span></td>


<td colspan="1" valign="top" width="200"><input type="button" onClick=window.open('ContractorExpenseAddMileage.a sp?IID=<%=A%>','AddMileageWindow','width=600,heigh t=250,toolbar=yes,location=yes,directories=yes,sta tus=yes,scrollbars=yes,copyhistory=yes,resizable=y es') value="Add Mileage >"></td>

</form>

As you see, by Submitting "Add Item" in form action I am submitting the form and opening other form.
My problem is with other button named " Add Mileage" when I click on the button I want to validate the text box first then open other window so basically my form is not submitting so I can't request.form the text box value!!!!!

What should I do? :(
Well it all depends on what you require of the behavior of the app.

You can't have it both ways. You either need to validate the form prior to submission, (i.e don't let them submit unless the form is correct) or you need to go ahead and let them submit the form, and do your checking on the other side with the request.form like above.

Either way you really only need 1 button. Then you just need to call your validating javascript from the onsubmit event of the form, like was displayed in the above example link.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function validate_required(field,alerttxt)
  3. {
  4. with (field)
  5. {
  6. if (value==null||value=="")
  7.   {alert(alerttxt);return false;}
  8. else {return true}
  9. }
  10. }function validate_form(thisform)
  11. {
  12. with (thisform)
  13. {
  14. if (validate_required(email,"Email must be filled out!")==false)
  15.   {email.focus();return false;}
  16. }
  17. }
  18. </script>
  19.  
Expand|Select|Wrap|Line Numbers
  1. <form action="nextwindow.asp"
  2. onsubmit="return validate_form(this)"
  3. method="post">
  4.  
I guess if this still doesn't answer your question please provide more info on exactly what you are trying to accomplish. Are you trying to do a calculation for the user before he proceeds to the final window? Or are you trying to actually do a validation before the user submits?

Again I must say that if you are wanting them to submit the form either way then just use your request.form method on the next page to check the value and display your messages then.

I do think I see what you are trying to do. You are trying to bring up a popup window with information on it if they submit the form a certain way (with the value entered)? If so you can just do a pop up window on the body onload event on the ContractorExpenseAddItem.asp page, that will get its info from the request.form data.

All kind of guesses though since I'm not sure what your final goal is here.
Apr 2 '08 #4
F159753
31
Thanks a bunch.

how should I complete the following code:

onClick="javascript:window.open('abc.asp'

if I want to send a parameter with it without submitting the form?

It should be something like the following line, but it is not right!!!

onClick="javascript:window.open( 'ContractorExpenseAddMileage.asp?A=) + escape(document.theForm.userName.value)"

Thanks
Apr 2 '08 #5
F159753
31
oh Jeff,
Thank you sooooooooooooooooooooo much. I could write the correct line and it is working :)

<input type="button" value="Add Mileage >" onClick="javascript:window.open( 'ContractorExpenseAddMileage.asp?WED=' + escape(document.Formd.WeekEndingDate.value))" />

Thanks
Faranak
Apr 2 '08 #6
jeffstl
432 Expert 256MB
oh Jeff,
Thank you sooooooooooooooooooooo much. I could write the correct line and it is working :)

<input type="button" value="Add Mileage >" onClick="javascript:window.open( 'ContractorExpenseAddMileage.asp?WED=' + escape(document.Formd.WeekEndingDate.value))" />

Thanks
Faranak
Excellent!

Glad I could help
Apr 2 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Venkat | last post by:
Hi All, I know that this is not right forum to address this issue, i had posted this problem in Javascript forum but of no use, i appreciate if any one of you can answer or point me to some...
1
by: Venkat | last post by:
Hi All, I am not able to access a dll function from a remote script using ActiveXobject when an output parameter is used, but i could able to access the same when no output parameter is used....
3
by: annon | last post by:
I've noticed that some problems come up frequently that are of importance in writing web pages, because they're pretty fundamental points. For general reference, here are some collected...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
7
by: Oleg Konovalov | last post by:
Hi, I am trying to pass a bunch of checked checkboxes (Javascript array) from page1 to the Java action class on subsequent web page (page2). (on page 1 I have a bunch of DB rows with a checkbox,...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
4
by: Nathan Sokalski | last post by:
I am a beginner with AJAX, and have managed to learn how to use it when passing single parameters, but I want to return more than one value to the client-side JavaScript function that displays it....
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
9
by: ismailc | last post by:
Hi, I need help please I usually code in coldfusion but now i want to create 2 text html files where i pass a parameter on href? This normally works in coldfusion! Page1 <a...
3
by: willyWEB66 | last post by:
Hi everyone, I'm having problem with the sequence of execution for xml.onload. It works fine if your not passing parameters to onload event but my code needs to pass parameter to its function. I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.