Solved

Help setting input value

Posted on 2011-03-20
2
308 Views
Last Modified: 2012-05-11
In the following code snipplet, I'm creating a "select" button. Clicking the btnSelect button, should set the value of the input field called input-value.

When I click on the button now, nothing happens. No error but now update to the input-value field either.

How can I update the input-value field when the btnSelect is pressed.


The input field looks like this:

<input id="input-value" name="input-value" type="text" value="">

Open in new window

$.ucm.emuseumSearch3(text, function(ucmResponse) {
						// draw the results to the page
						var resultHtml = "";
						var searchResults2 = ucmResponse.ResultSets['objectRS'];
						for (var rowIndex in searchResults2.rows) {
							var row = ucmResponse.getRow("objectRS", rowIndex);
							resultHtml = resultHtml + "<tr><td>" + row.id +
								"</td><td>" + row.title + "</td>" +
								"<td><button id='btnSelect' name='btnSelect' value='"+row.id+"' onclick='document.getElementById(\'input-value\').value=this.value'>Select</button></td></tr>\n";
						}
						$("#searchResults2 tbody").html(resultHtml);
						$("#searchResults2").show();
					});

Open in new window

0
Comment
Question by:greddin
2 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35178057
please share the html code for btnSelect button, or try something like this

<input id="btnSelect" name="btnSelect" type="button" value="Select"/>


$("#btnSelect").bind("click", function(){
   $("#input-value").val("somevalue");
});

0
 
LVL 42

Accepted Solution

by:
David S. earned 500 total points
ID: 35179242
Perhaps the nested inner quotes are a problem.
"<td><button id='btnSelect' name='btnSelect' value='"+row.id+"' onclick='document.getElementById(\"input-value\").value=this.value'>Select</button></td></tr>\n";

Open in new window

Why are you using an inline event handler (onclick attribute) anyway?
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now