INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

asp/java mix

asp/java mix

(OP)
I need to retrieve a form field name from my page and dump it into some java script. The form fields are created dynamically in an asp page.

here are the pertinent parts of the code:

chkLeave(var) {

if (window.document.form1.frmLeaveCode.value==window.document.form1.frmCode.value)

So I need help in making "frmLeaveCode" and "frmCode" above dynamic. Q: how can I make those "var & frmLeaveCode" or "1frmLeaveCode" where var=1


//var is the progressive number that allows me to identify each form field

// in my asp page the form is created using the following (I have cleaned it up a bit for simplicity):



<select name="<%=intCount & "frmLeaveCode"%>" onChange="chkLeave(<%=intCount%>);">

Hope this makes sense.

Mike...

RE: asp/java mix

Get the data from the form collection into a variable and response.write it into the appropriate place in the code.



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: asp/java mix

Mike
Your original post does not name sense for me...
Are you tryinh to create one page with 2 forms inside? Why?
You can create dynamic elements like
<select name="<%=intCount %>frmLeaveCode" onChange="chkLeave('<%=intCount%>');">
so it will be converted to something like
<select name="1frmLeaveCode" onChange="chkLeave('1');">
<select name="2frmLeaveCode" onChange="chkLeave('2');">
etc;
for form validation you can use javascript or jquery and get all form elements, loop throw and chack values...
after submitting form on next page you have requesr.form object which was all form elements inside with values. Which part of that is your problem?



RE: asp/java mix

(OP)
gk53 correct.

In fact that is what I am doing.

Essentially, my form has a member drop down list. When the user changes that name to a different user I want to have a new form filed pop up on the form.

BUT if they select a new member and then change back to the original member I want to have that form field disappear.

So my chkLeave() need to evaluate if there was a change. PROBLEM is I have several members on the same form.

I use exactly what you have on the form side:

<select name="<%=intCount %>frmLeaveCode" onChange="chkLeave('<%=intCount%>');">

My question is how do I handle that on the java side
Here is what I have so far (only code needed for discussion).

if (window.document.form1.frmLeaveCode.value==window.document.form1.frmLeaveCode.value)
{
div.style.display = 'none';
}
else
{
div.style.visibility = 'visible';
}


So my question is how do I concatenate the 'intCount' value to the 'form1.frmLeaveCode.value' in the javascript side.

RE: asp/java mix

Let me clear understand what is page logic.
1. You have a form with original member info.
2. When in member dropdown list user changed selection you displaying somewhere identical form with selected user. right?
Is that form shows in the same window or it is popup? If popup how it was done iframe, winodw.open, modal, div with overlay?
3. is "popup form has another member dropdown and works similat to original?
4. Why you need to find oth values? If you need to compare original value to dinamic one, why no to send in "dynamic" item value as paramemter?

And if you really still need that
allLeaveSelections = $('[id^=frmLeaveCode]');
jquery which return to you array of all elements which id starts from "frmLeaveCode"
of couse you need to modify
<select name="<%=intCount %>frmLeaveCode" onChange="chkLeave('<%=intCount%>');">
to <select id="<%=intCount %>frmLeaveCode" name="<%=intCount %>frmLeaveCode" onChange="chkLeave('<%=intCount%>');">
and include link to jquery library which you can get on that link http://code.jquery.com/jquery-1.10.2.js, copy from browser and save in "jquery-1.10.2.js" file and include this javascript in your page

RE: asp/java mix

forum216: Javascript

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: asp/java mix

@ChrisHirst

I directed the OP here from the js forum.
the issue (as originally expounded) was how to use ASP to insert variables into rendered client-side javascript. I provided a solution along the lines of

CODE

var someVar = "<%= some asp variable %> "; 
however the OP never responded; so I assume that this was not a solution for him/her (although I see he now says he is using it...)

i have read the later post and wonder about this line

CODE

if (window.document.form1.frmLeaveCode.value==window.document.form1.frmLeaveCode.value) 

my guess is that will always evaluate to TRUE winky smile

RE: asp/java mix

(OP)
Theoretically no, because each 'frmLeaveCode' should have the 'intCount' value concatenated to it.

So it might look like:

if (window.document.form1.1frmLeaveCode.value==window.document2form1.2frmLeaveCode.value)

OR

if (window.document.form1.1frmLeaveCode.value==window.document.form1.1frmLeaveCode.value)

OR

if (window.document.form1.3frmLeaveCode.value==window.document.form1.2frmLeaveCode.value)

My question is "How do I concatenate the intCount value to the frmLeaveCode in the javascript function.

RE: asp/java mix

if (window.document.form1.<%= intCount %>frmLeaveCode.value==window.document.form1.<%= intCount - 1%>frmLeaveCode.value)
but i do not think it will work

RE: asp/java mix

Tell you what: provide a link to your site where we can see this in action or paste the rendered code you are using.

Your posts are unfortunately not clear enough for (at least) me to grok fully what you want. Your original question however has been asked and answered at least twice.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close