Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help setting input value

Posted on 2011-03-20
2
Medium Priority
?
314 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
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 43

Accepted Solution

by:
David S. earned 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…
Suggested Courses

618 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