2

I don't know if it is possible to generate using this way.
I have a set of dynamic radio buttons.
When user click on add row radio button, the Javascript will generate the value for the row radio button.

function addRow(tableID) {
	var table = document.getElementById(tableID);

	var rowCount = table.rows.length;
							// limit the user from creating fields more than your limits
		var row = table.insertRow(rowCount);
		var colCount = table.rows[0].cells.length;

		for(var i=0; i<colCount; i++) {
			
			var newcell = row.insertCell(i);
			newcell.innerHTML = table.rows[1].cells[i].innerHTML; //row[which table u need to duplicate]
			table.rows[rowCount].cells[0].innerHTML = rowCount;
			}


}

<input type="radio" name="BX_related[]" size="1" value="How to change this value using javascript?">

2
  • So what issue you are facing? Commented Aug 26, 2015 at 8:01
  • For example, I have dynamic radio button and I added 3 row for my radio button. Then I click on second row. The value will show in 1st row and rest of it is a Undefined offset error. So I think if can I insert the value when I crated a new row for user maybe can solve the problem but I don't know the correct ways. Commented Aug 26, 2015 at 8:51

1 Answer 1

3

With a reference to your input element you can change value like so:

inputRef.value = 'Whatever you want';
Sign up to request clarification or add additional context in comments.

3 Comments

Sorry I not so familiar on Javascript. I just try to insert id="radio" value="1" for my HTML radio button. Javascript var radio = document.getElementById(radio); radio.value = rowCount; //rowCount stand for how many row was user clicked. Error : Uncaught TypeError: Cannot set property 'value' of null
In the document.getElementById what does the radio variable contain? Or did you mean to pass it in as a string?
suppose "1" because I preset the value equal to 1 and I want to change the radio value according the user has added the row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.