How to populate drowndown box using spring+hibernate,jsp [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am new in this world...so please help..I want idea from u people...I have 4 dropdown list ..and I wanted to populate select box on selecting another selectbox2 .... using database values....so how should I proceed ..i need your help...and i have already created the database for that...and I am good with database....so please help me..forward me some link also..I have short span of time..within that i have to complete..please help.

In Spring 3.0 you can populate values in the dropdown as follows:
#ModelAttribute("webFrameworkList")
public List<String> populateWebFrameworkList() {
//Data referencing for web framework checkboxes
List<String> webFrameworkList = new ArrayList<String>();
webFrameworkList.add("Spring MVC");
webFrameworkList.add("Struts 1");
webFrameworkList.add("Struts 2");
webFrameworkList.add("JSF");
webFrameworkList.add("Apache Wicket");
return webFrameworkList;
}
In JSP
<form:select path="favFramework">
<form:options items="webFrameworkList"/>
</form:select>
Now you can modify the logic as per your requirement that you want.

Related

How to disable/enable text box depends on Enum? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am working in MVC C#. I have a table with Enum values. I got 2 conditions in Enum as On and Off. I want my text box to be Enabled during On and Disabled during Off. How to do this ? kindly help.
My text box as follows:
<div ><p class="form_text1">Start</p> <input type="text" id="EditStart" name="EditStart" class="form-control">
</div>
If you want a bit more of a generic approach, you can do this through C# instead of JavaScript. However, I am unsure how you are getting this enum so my answer might not work. Hope this helps.
public static MvcHtmlString EnumTextBox(this HtmlHelper<TModel> htmlHelper,
YourEnum enum)
{
object attributes = null;
if(enum == YourEnum.Off)
{
attributes = new
{
disabled = "disabled"
};
}
return htmlHelper.TextBox("YourTextBoxName", null, attributes);
}
Note: I did not test this, just wrote it out from head.

Unable to get data from dynamically created textfield in javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a small project where i created text fields based on user input.
$('#arraySizeButton').click(function() {
var arraySize = $("#arraySize").val();
if(arraySize=='') {
alert("Enter Some Text In Input Field");
}else{
var count = arraySize;
var html = [];
while(count--) {
html.push("\<input type='text' id='inputTextField", count, "'>");
}
$('#inputTextFieldsarea').append(html.join(''));
}
});
I want to create a dynamic program based on above code and retrieve data from textfields to an array. Appreciate your help.
Did you mean this?
html.push("<input type='text' id='inputTextField"+count+"'/>");
What you should do is add a [] to the name of the input, to let the html form know that this is an array.
You should do something like that:
html.push("\<input name='field[]' type='text' id='inputTextField", count, "'>");
And using php to get the content of all the POSTed fields you could simply check
$_POST['field']
which is an array.
EDIT: IF you want to do this using jquery as you stated in your comment, then you could do it like that:
$('[id^="inputTextField"]').each(function() {
alert($(this).val());
});

jquery cookies / javascript cookies [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm have planned to design a jewelry website with add to cart option. but i still don't know how to keep the selected items on the cart even after refreshing the page through jquery. so if anyone knew please provide an step by step example or tutorial.
You can use a simple JQuery get method which links to a PHP file which adds the product to the Site cookies; when you want to view the cart, explode the cookie.
An example:
$(document).ready(function(){
$("#product").click(function(){
// However you want to get the item ID
var itemID = document.getElementById("productID").value;
$.get("/inc/addtocart.php", { item: itemID }, function(data){
document.getElementById("result-sec").innerHTML=data;
});
});
});
Your PHP file will look like this:
if(isset($_GET['item'])){
$_COOKIE['cart_ids'] = $_COOKIE['cart_ids'] . '::' . $_GET['item'];
}
To view your cart items, simply:
$all_items = explode("::", $_COOKIE['cart_ids']);
foreach($all_items as $item):
echo $item . "<br />";
endforeach;

Fire Event Immediately if Checkbox is Checked, Calling Server-Side PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
These are my checkboxes:
<input type="checkbox" name="cb1" onclick="check(this)">Batas Wilayah</input><br>
<input type="checkbox" name="cb2" onclick="check(this)">Lokasi Masjid</input><br>
This is my PHP code:
<?php
function check() {
if ($('cb1').is(":checked")) {
$.getScript("batas.php");
} elseif ($('cb2').is(":checked")) {
$.getScript("daftar.php");
}
}
When cb1 or cb2 are checked, I want to immediately call a server-side PHP script with the form data. Can anyone point me in the right direction?
jQuery.getScript is specifically for loading javascript. In theory it should still work fine but using a AJAX jQuery.get request is worth a shot.
$.get("batas.php", function( data ) {
alert(data);
});
In the above code data is the data returned from the php script.

How to add new text field when button is clicked [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a form for my client. My client require to create a dynamic for him.
Suppose, I want to insert 1 record in main table of mysql, and record multiple records in secondary table which has reference key of main table. I don't know how many records against the main table, it maybe one at time or multiple records at time. I want to do it with single form. If client click add more button it show another text field to insert more data.
how I can do it ?????
It would be possible using pure javascript
like this
<input type="button" onclick="addInput()"/>
<span id="responce"></span>
<script>
var countBox =1;
var boxName = 0;
function addInput()
{
var boxName="textBox"+countBox;
document.getElementById('responce').innerHTML+='<br/><input type="text" id="'+boxName+'" value="'+boxName+'" " /><br/>';
countBox += 1;
}
</script>
This is possible through the jquery/javascript.
So you can use this reference :http://www.mkyong.com/jquery/how-to-add-remove-textbox-dynamically-with-jquery/
Just try it!!
here is the code:
function generateTextBox()
{
var mainDiv=document.getElementById('options');
alert(mainDiv);
var newBreak=document.createElement('br');
mainDiv.appendChild(newBreak);
for(var i=1;i<=4;i++)
{
var newTextBox=document.createElement('input');
var newBreak1=document.createElement('br');
var newBreak2=document.createElement('br');
var newBreak3=document.createElement('br');
var text = document.createTextNode("Option"+i);
newTextBox.type='text';
newTextBox.setAttribute('id','txtAddr'+i);
alert(newTextBox+"2");
mainDiv.appendChild(text);
mainDiv.appendChild(newTextBox);
mainDiv.appendChild(newBreak1);
mainDiv.appendChild(newBreak2);
mainDiv.appendChild(newBreak3);
}
}
This isn't php related, you'll need to dynamically add to the form using javascript.

Categories

Resources