Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Sponsored Links

Discuss "edit with text box" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Reply « Previous Thread | Next Thread »
 
LinkBack Thread Tools Display Modes
  #1  
Old August 20th, 2008, 08:28 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 128
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default edit with text box

hi
i m displaying list of records with edit and delete button.code is here
Code:
If(Not rstSettings.EOF) then
		   While Not rstSettings.EOF 		 		
			lCounter = lCounter + 1
			StrDisplay = StrDisplay & "<TR class=""Row" & lCounter Mod 2 & """>"					
			StrDisplay = StrDisplay & "<TD align=""left"">"& rstSettings("ProtocolSettingNo")&"</TD>"
			StrDisplay = StrDisplay & "<TD align=""left"">"& rstSettings("DocumentTypeNo")&"</TD>"
			StrDisplay = StrDisplay & "<TD align=""left"">"& rstSettings("DocumentFormatNo")&"</TD>"
			StrDisplay = StrDisplay & "<TD align=""left"">"& rstSettings("PartnerID")&"</TD>"
			StrDisplay = StrDisplay & "<TD align=""left"">"& rstSettings("SettingValue")&"</TD>"
			StrDisplay = StrDisplay & "<TD align=""right"" colspan=""2""><input type=""button"" name='btnEdit_"& vlMemberID &"' value=""Edit"" onClick=""fnNextPage('"& vlMemberID &"','"& Server.URLEncode(rstSettings("ProtocolSettingNo")) &"');"">"
			StrDisplay = StrDisplay & "<input type=""button"" name='btnDelete_"& vlMemberID &"' value=""Delete"" onClick=""fnDelete('"& vlMemberID &"','"& rstSettings("ProtocolSettingNo") &"','"&rstSettings("DocumentTypeNo")&"','"&rstSettings("DocumentFormatNo")&"','"&rstSettings("PartnerID")&"','"&rstSettings("SettingValue")&"');""></TD>"
			StrDisplay = StrDisplay & "</TR>"
			rstSettings.MoveNext
		  Wend 
		Set objData = nothing
		Set rstSettings = nothing
	Else		
		StrDisplay = StrDisplay & "<TR class=""Row1"" ><TD Colspan=7><font color=red><B>No Protocol Settings Found.<B></TD></TR>"
	End If
what i wanted to do is as user click on edit button then this coulmn "<TD align=""left"">"& rstSettings("SettingValue")&"</TD>" should display value in text box for edit purpose and edit button should display save button.as user click on save button then original column will display without text box and button will be edit button.

how to do this?
__________________
Love is physical attraction and mental destruction
Reply With Quote
Sponsored Links
  #2  
Old August 20th, 2008, 08:51 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 819
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

Unless you want to have several requests to the server, your best bet would be to use JavaScript. If you want to use JavaScript, this thread can be moved to the appropriate forum.
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old August 20th, 2008, 09:02 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 128
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default

i dont mind for javascript bcoz the solution is going to give by you guys only.

cheers!!
Reply With Quote
  #4  
Old August 20th, 2008, 09:36 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 819
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

First, have your ASP generate textboxes inside each cell and set their display property to none. The resulting markup should look something like this:

Code:
<tr>
    <td><span id="textcolumn1row1">Some text</span></td>
</tr>
When you click "Edit", it would look like this:

Code:
<tr>
    <td><span id="textboxcolum1row1"><input type="text" id="textbox1" /></td>
</tr>
To achieve this, you'll need to create a JavaScript function that accepts parameters to determine which row we're editing. When the "Edit" button is clicked, it will toggle the display property between inline and none (i.e. style="{display: none;}"). This, in turn will display your textboxes or text for that row.

Keep in mind that each <span> must have a unique ID that you can use to pass to the function.

Comments on this post
guddu agrees: Thanked Post
Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
guddu (August 20th, 2008)
  #5  
Old August 20th, 2008, 10:20 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 128
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default

hi
in this line i m getting javascript syntax error
Code:
StrDisplay = StrDisplay & "<TD align=""left""><span id='txtRow_"& lCounter &"'>"& rstSettings("SettingValue")&"</span><span style=""display:none"" id='txtBoxRow_"& lCounter &"'><input type=""text"" value="""& rstSettings("SettingValue") &""" name='txtBoxRow_"& lCounter &"' ></span></TD>"
Reply With Quote
  #6  
Old August 20th, 2008, 10:25 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 128
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default

sorry not a error .JMH this is the what u said to do me?

now next?
Reply With Quote
  #7  
Old August 20th, 2008, 10:32 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 128
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default

hi
now i javascript function i written this code
Code:
document.getElementById("txtRow_" + vlCounter ).style.display = "none";
document.getElementById("txtBoxRow_" + vlCounter ).style.display = "";
what next?
Reply With Quote
  #8  
Old August 20th, 2008, 10:42 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 819
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

So you'll need something like this:

Code:
function makeVis(textSpanID,boxSpanID,action) {
    if action == "edit"
        {
             document.getElementById(textSpanID).style.display = "none";
             document.getElementById(boxSpanID).style.display = "inline";
        }
    else
        {
             document.getElementById(textSpanID).style.display = "inline";
             document.getElementById(boxSpanID).style.display = "none";
        }
 }
Then set the onclick of your buttons to this function. I'm not strong with JavaScript, so there may need to be some corrections made.
Reply With Quote
  #9  
Old August 20th, 2008, 10:53 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 128
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default

that is already i have done.let me try whole stuff now.catch u later.

Thanks a lot.
Reply With Quote
  #10  
Old August 20th, 2008, 10:58 AM
guddu's Avatar
Barn Frequenter

 
Join Date: Jul 2008
Location: Oxford UK
Posts: 128
Thanks: 6
Thanked 3 Times in 2 Posts
Rep Power: 1
guddu is on a distinguished road
Default

forgot to ask u after submit how i will get value of
name='txtBoxRow_"& lCounter &"'

this text box
Request.form("'txtBoxRow_")?
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Forms] Field that is a link (rs) and/or text field question Rebelle ASP Development 14 August 12th, 2008 08:43 AM
Text or List option plus Rebelle JavaScript Programming 8 June 17th, 2008 12:27 PM
text display problem todd2006 HTML & CSS Help 10 May 7th, 2008 08:14 PM


All times are GMT -4. The time now is 03:23 PM.



Content Relevant URLs by vBSEO 3.2.0