问题描述:

I am having this code how to use this using backbone.js. I am planning to implement a javascript code in rails. The code below gives a dropdown menu with some default and one "write your own question" facility, where one can write there own question just by clicking on this option.

One can write their own question on the textbox which appears below the dropdown menu when clicked on "write your own question" otherwise that text box is hidden.

I would like to store the string written by the user to my database or rails model.Please suggest me some way to do this using backbone.js

<select onchange="CheckOther(this);">

<option value="Select one question....">Select one question...</option>

<option value="On which street did you grow up?">On which street did you grow up?</option>

<option value="What was your first phone number?">What was your first phone number?</option>

<option value="What was the make of your first car?">what was the make of your first car?</option>

<option value="Write your own question...">Write your own question...</option>

</select>

<input type="text" id="TextBox1" name="TextBox1" style="display:none;" />

<script type="text/javascript">

function CheckOther(selectBox)

{

if (selectBox.selectedIndex == selectBox.options.length - 1)

{

document.getElementById("TextBox1").style.display = "inline";

}

else

{

document.getElementById("TextBox1").style.display = "none";

document.getElementById("TextBox1").value = "";

}

}

</script>

相关阅读:
Top