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

Dynamically naming form name

Dynamically naming form name

(OP)
I have a form that uses a dynamic name based on a value.

the value is based on the id of the record. if I use

CODE

onChange="document.form1.submit()" 
how can I write the 1 in form 1 to the variable?

CODE

onChange="document.form++id++.submit()" 

or something like that?

RE: Dynamically naming form name

onChange="document.form"+id+".submit()"

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey

RE: Dynamically naming form name

(OP)
using this as id3 is the variable name
[code]
onChange="document.form"+id3+".submit()"
[/code
does not appear to work. on my viewer, "+id3+".submit()" is red as if it isn't written properly so the form is not submitting on the change.

RE: Dynamically naming form name

Is id3 a valid variable? Does it contain a value?
You need to share all of your code.

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey

RE: Dynamically naming form name

Hi

CODE

onChange="document.forms['form'+id3].submit()" 

Feherke.
feherke.ga

RE: Dynamically naming form name

(OP)
Yes id3 is a good variable. I checked the page source and verified that each row does have the id3 form name. the only issue now is passing it. with the submit.

feherke

CODE

onChange="document.forms['form'+id3].submit()" 
looks good on the viewer but it does not submit anything on the page. My guess would be the form names aren't matching up, or something like that. Like the form name does not qualify and therefore does not submit.

RE: Dynamically naming form name

(OP)
Just a quick question about this, if I use the

CODE

onClick="this.form.submit();" 

and each row does have a different form name, shouldn't this work? It doesn't, but shouldn't it?

RE: Dynamically naming form name

Hi

On this point I can only second Lyndon's request :

Quote (LyndonOHRC)

You need to share all of your code.

Feherke.
feherke.ga

RE: Dynamically naming form name

(OP)
here is the code for the page. As stated, it is sending the information from each row(form)


CODE

<!--#include virtual="myconnectionstringp"-->

	
<%
casetype = request.querystring("casetype")
if casetype = 1 then
	sqltype = "open"
elseif casetype = 2 then
	sqltype = "closed"
else
	sqltype = "open"
end if	
%>



<body>
<table cellpadding="4" cellspacing="0" align="center">
	<tr>
		

<% set orders1 = conn.execute("select * from orders where case_ = '"&sqltype&"'") // i know * shouldn't be used

	
		
		
		irowcolor = 0
if not orders1.eof then
do while not orders1.eof
id3 = orders1.fields.item("id").value
'**** check shipping method ************
vmethod = trim(orders1.fields.item("method_").value)
	if vmethod = "email_" then
		vmethod1 = "Email"
	elseif vmethod = "kit_" then
		vmethod1 = "Ship Kit"
		end if
'**********************************************		
		if irowcolor mod 2 = 0 then
			rowcolor = "#8699C4"
			auto1 = "auto-style4"
		else
			rowcolor = "#86AACE"
			auto1 = "auto-style3"
		end if
		vform = "form"&id3
		'response.write vform
%>
	<form name="<%=vform%>" action="statuschangeasp.asp" method="post">

	<tr style bgcolor="<%=rowcolor%>">
		<td  ><%=orders1.fields.item("id").value%></td>
		<td  >
		<span id="c10_ctl">
		
		<select  onChange="document.forms['form'+id3].submit()"  name="change_">
		<option selected="<%=orders1.fields.item("istatus_").value%>" value="<%=orders1.fields.item("istatus_").value%>"><%=orders1.fields.item("istatus_").value%></option>
		
		<option value="Shipped">Shipped</option>
		<option value="Sent">Sent</option>
		<option value="paid1">Paid PayPal</option>
		<option value="paid2">Paid Check</option>
		<option value="received">Received</option>
		<option value="processing">Processing</option>
		<option value="processed">Processed</option>
		<option value="returned">Returned</option>
		<option value="Pending">Pending</option>
		</select>
			<input name="id" type="hidden" value='<%=orders1.fields.item("id").value%>' class="auto-style4"/>
			
			</span>
			</td>
		<td class="auto-style3" ><%=orders1.fields.item("tracking_").value%></td>
		<td class="auto-style3" ><%=vmethod1%></td>
		<td class="auto-style3" ><%=orders1.fields.item("first_").value%></td>
		<td class="auto-style3" ><%=orders1.fields.item("last_").value%></td>
		<td class="auto-style3" ><%=orders1.fields.item("state_").value%></td>
		<td class="auto-style3" ><%=orders1.fields.item("email_").value%></td>
		<td class="auto-style3" ><%=orders1.fields.item("phone_").value%></td>
		<td class="auto-style3" ><%=orders1.fields.item("mod1_").value%></td>
	</tr>
	
<% 
irowcolor = irowcolor + 1
orders1.movenext
loop
else
%>
</form>
<tr>
	<td class="auto-style1">There are no active orders at this time.</td>
</tr>
<% end if %>
</table>
	
</body>

</html> 

RE: Dynamically naming form name

Hi

When Lyndon asked you

Quote (Lyndon)

Is id3 a valid variable?
he certailnly meant that "Is id3 a valid JavaScript variable?". Well, seems it is not.

Maybe this :

CODE --> ASPĀ (?)

onChange="document.form<%=id3 %>.submit()" 
( Just a guess, as I have no idea about ASP. )

Feherke.
feherke.ga

RE: Dynamically naming form name

(OP)
I understand his question now.

No it is not a valid js variable. I have tried your example in the beginning but JS does not play well with asp tags at all.

So how do I make my asp variable into a js variable?

RE: Dynamically naming form name

Hi

Quote (Bambamn007)

So how do I make my asp variable into a js variable?
Just generate JavaScript code where you output the ASP variable's value on the JavaScript assignment's right hand side :

CODE

<script>
var jsvar = '<%=aspvar %>'
</script> 

Note that the above will fail if aspvar contains multiline string or string with escape sequences which will interfere with the JavaScript string literal syntax. Also you should make sure that characters with special meaning in HTML get transformed into character entities. No idea how. You will need to consult the ASP documentation on escaping and quoting. But for numeric values the above code should work fine. However this was just an answer to your question, the code itself is nothing better than the earlier one ( 27 Jun 14 9:10 ).

Feherke.
feherke.ga

RE: Dynamically naming form name

(OP)
I now have the form name being dynamic with the id. thanks to everyone.

However, this did not stop the issue of the onchange sending the values for each record. I thought making each record having a different form name would solve this, but it did not.

I am now unsure where to go. Could be asp, could be js, could be html.... I just don't know.

But thanks to everyone who gave me advice.

RE: Dynamically naming form name

(OP)
PROBLEM SOLVED!

Here is the solution. One must pay attention where things lie on a page that contains html, asp, and JS.

I had the clode form tag </form> outside of the loop where I was getting records from the database. Once the tag was moved into the loop, viola!

Thanks so much to everyone for their patience and guidance.

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