w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Display alert based on the background color of a drop down select option
Something like this should do what you want: For Each opt In document.getElementById("frmNew").options If opt.selected And opt.style.backgroundColor = "red" Then MsgBox "This user is banned." End If Next However, as @DanielCook said, just checking the actual name against a list of banned users would be a better approach, because the application logic is less shrouded that way: Set bannedUsers = CreateObject("Scripting.Dictionary") bannedUsers.Add "johnsmith", True bannedUsers.Add "cmanson", True ... For Each opt In document.getElementById("frmNew").options If opt.selected And bannedUser.Exists(opt.text) Then MsgBox "This user is banned." End If Next

Categories : HTML

Activate a textbox if I select a particular option in drop down box in html without using java
It is not possible to make a input tag change it's visibility without some script function. It is possible to validate your input via your server side scripts. If you need more information, please ask.

Categories : HTML

Populating a HTML select statement with JavaScript
without seeing what x is exactly, here is a simplified options populator routine: var streetSelector=document.createElement('select'); streetSelector.id='street'; for (i=0;i<x.length;i++){ streetSelector.appendChild(new Option( x[i].childNodes[0].nodeValue)); }

Categories : Javascript

jQuery code in if statement not running even though alert in if statement happens
Try to add position:absolute; or position:relative; (and at least initial left and top properties) to styles of #tabViewWindow. left property only applies to elements with that properties. Or if you want to leave position of element static you can animate margin-left property: $('#tabViewWindow').animate({'margin-left' : '100%'}, 500);

Categories : Javascript

IF statement inside WHILE - PHP, MySQL and HTML dropdown select
You do not need a while if you want to fetch just one row. First, fetch the row and get what option should be selected. <?php // better use 'fetch_assoc' here $row = mysql_fetch_assoc($result) or die(mysql_error()); $income_select = $row['income_select']; $daily = ($income_select=='daily'); $weekly = ($income_select=='weekly'); ?> And in form, use it like this: <option value="daily" <?php if($daily) echo 'selected'; ?>>Daily</option> <option value="weekly" <?php if($weekly) echo 'selected'; ?>>Weekly</option> If your PHP settings and version allow it, you can even use this: <option value="daily" <?= $daily ? 'selected' : '' ?>>Daily</option> <option value="weekly" <?= $weekly ? 'selected' : '' ?>>Weekly&

Categories : PHP

Create a conditional statement for
Try this : $("#category").on('change',function ( $("div.food").hide( ); var _lower=$(this).val(); var _value=_lower.charAt(0).toUpperCase() + _lower.slice(1); //just noticed that there is a uppercase char there... $("#div"+_value).show() )}); p.s. I don't know if all those FOOD divs are hidden by default , but if they not so add this : (by css) div.food { display:none; } (or by Js) $("div.food").hide();

Categories : Jquery

how to use select option value in html main body as variable in php sql statement same page
Because php is a server based script language, you have to do an asynchronus connection to the php file. You can do so with AJAX for example. Load the php file with the selected value as get or post parameter. Then you can output the result of the sql statement in the php file and get this value in the ajax engine back.

Categories : PHP

nested drop down box and multi-select box based on each drop down in rails?
I would need a bit more info, especially some code examples to really help you. However here is some resources to get you started. When you have written something, then please come back and i/others can help you further :) Railscasts #88 - Dynamic select menus (revised) - This railscast explains how to make a dynamic select/dropdown menu, fx changing the materials when selecting a category. Railscasts #196 - Nested model form (revised) - This railscast shows how to dynamically add associated records with accepts_nested_attributes_for. This is not necessarily important to you but will at least help you to understand how to create a multi record form. Update: How to dynamically populate a dropdown/select menu Ok so what you want is to have a select menu (also called dropdown menu) of a

Categories : Ruby On Rails

jQuery to automatically pre-select multiple options from several drop down lists based on user selection from another drop down list
The easiest way that comes to mind is the following: var positions = { QB : ['SPD', 'AGI', 'INJ', 'AWR', 'TPOW', 'ELUS', 'TACC', 'TDEP'], HB : ['SPD', 'AGI', 'ACC', 'AWR', 'CARY', 'TRCK', 'ELUS', 'BCV'], FB : ['SPD', 'AGI', 'AWR', 'TRCK', 'CTCH', 'RBST', 'RBFT', 'IMPB'] // fill in the rest of this object yourself } $('#position').change(function(){ // caching the selected value: var v = this.value, // retrieving the array stored under the relevant key: arr = positions[v], // getting all the select elements whose 'id' starts with the string: attribs = $('select[id^="attribute_type_"]'); // iterating each of those selects: $.each(attribs, function(i,v){ /* finding the 'option' whose value is equal to that stored in

Categories : Jquery

HTML 5 drag and drop How to figure out whether an element accepts a drop
So - we figured out a way to do this. You can read the dataTransfer.types property which returns a list of the types added via setData. So if you use a custom string as one of those types, you can check that to verify the existence of drag data that you added. e.g. event.dataTransfer.setData("SpecialNameOfDragSource", data); Then in dragover you can see if this type exists : function ondragover(ev) { if (ev.dataTransfer.types && ev.dataTransfer.types.indexOf("SpecialNameOfDragSource") > -1) { // cancel the event } }

Categories : HTML

Compiling a conditional alert message based on various selections made in drop down boxes
To Read Select Option Value $('#selectId').val(); To Set Select Option Value $('#selectId').val('newValue'); To Read Selected Text $('#selectId>option:selected').text(); In the #selectId, put your html element's id and you should be fine!

Categories : Javascript

I want to add alert dialog within if else statement in android
Change this line AlertDialog.Builder alt = new AlertDialog.Builder(getApplicationContext()); to AlertDialog.Builder alt = new AlertDialog.Builder(arg0.getContext()); and you should change arg0 to something meaningful like view or v. If that doesn't work then please post the logcat so we can see what error you are getting. You need to use the appropriate Context for the situation and here you want the AlertDialog to use the Activity Context which is the same Context that your Button (or arg0) uses. Note MainActivity.this will do the same thing here as argo.getContext() but I was recently informed that it is bad practice for reasons such as if you want to re-use this code then you have to change the activity name part of the code. Its a less dynamic way of accessing the Context. He

Categories : Android

JS Statement for Client Side Alert in .aspx.vb
Have a look at the following jsfiddle. There's an input and a button. To get the text in the input I use the following: $('#inputId').val(); In my case inputId is comment, so in my case it's $('#comment').val();

Categories : Javascript

How to use id in switch statement and alert the message when the button is clicked
<p>Q : 1</p> <button class="lbutton" onclick="showAnswer(1)">Answer</button> <p>Q : 2</p> <button class="lbutton" onclick="showAnswer(2)">Answer</button> <p>Q : 3</p> <button class="lbutton" onclick="showAnswer(3)">Answer</button> function showAnswer( questionNumber ){ switch (questionNumber){ case 1 : alert('Answer 1'); break; case 2 : alert('Answer 2'); break; case 3 : alert('Answer 3'); break; case 4 : alert('Answer 4'); break; default : alert('sorry there was an error in program'); } } http://jsfiddle.net/qGGUg/

Categories : Javascript

Is there a way to change the border of select drop down on keyboard tab select?
You can change the styles of an element on focus (and blur) as follows: HTML: <select><option>a</option></select> <br/> <select><option>b</option></select> jQuery: $(function() { $('select') .focus(function() { $(this).css('border-color', 'red'); }) .blur(function() { $(this).css('border-color', 'black'); }); }); jsFiddle Demo EDIT: updated the example to use select boxes.

Categories : HTML

Mysqli "select" statement produces no results - but "update" statement with the same "where" works. Why?
In order to use num_rows on prepared statements you need to call store_result first. The manual also mention the above. here is a simple example: <?php // Your database info $db_host = 'localhost'; $db_user = ''; $db_pass = ''; $db_name = ''; $code = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20); if (!isset($_POST['email'])) { die('Please fill in the email field.'); } if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { die('Invalid email address'); } $con = new mysqli($db_host, $db_user, $db_pass, $db_name); if ($con->connect_error) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); } $sql = "SELECT first, last FROM users WHERE user = ?"; if (!$result = $con->prepare($sql)) {

Categories : PHP

SUM() works fine in select statement but returns NULL in Insert statement
Try select trade_matrix_id, sum(pl) into PLByMatrixID from vw_package where date (gen_timestamp) between '2012-05-01' and '2012-05-30' and trade_matrix_id between 30 and 60 group by trade_matrix_id;

Categories : SQL

Why hibernate always call "update" statement after using "select" statement in MySQL?
Most probably, one of the properties of your entity does not return the exact same value that is set by hibernate after loading. Do you have some if statements like null handling or anything like this in a getter or setter?

Categories : Java

How to write a SQL DELETE statement with a SELECT statement in the WHERE clause?
Shouldn't you have: DELETE FROM tableA WHERE entitynum IN (...your select...) Now you just have a WHERE with no comparison: DELETE FROM tableA WHERE (...your select...) So your final query would look like this; DELETE FROM tableA WHERE entitynum IN ( SELECT tableA.entitynum FROM tableA q INNER JOIN tableB u on (u.qlabel = q.entityrole AND u.fieldnum = q.fieldnum) WHERE (LENGTH(q.memotext) NOT IN (8,9,10) OR q.memotext NOT LIKE '%/%/%') AND (u.FldFormat = 'Date') )

Categories : SQL

ASP.NET <%# Eval("Statement") %> Removes HTML String in Statement?
To render as html you can try this: <asp:Literal Text='<%# Eval("VariableName") %>' Mode="PassThrough" runat="server" /> This requires that you have html (with color info) in VariableName, which may not be pretty. Alternative 1: But it will be better if you can add a public property say VariableColor (and leave VariableName unchanged): public Color VariableColor { get { return <condition>? Color.Red : Color.Empty; } } and use it like this: <asp:Label Text='<%# Eval("VariableName") %>' ForeColor='<%# Eval("VariableColor") %>' runat="Server" /> Alternative 2: Even better could be to create a public bool property (say IsDangerous) which evaluates the condition: public bool IsDangerous { get { return <condi

Categories : C#

Wrap a Select Statement in a Conditional Statement
In mysql you can do something like this select concat(if(g.statusid = 1, 'Pending', ''), if(g.statusid = 2, 'Assigned', ''), if(g.statusid is NULL, 'NoPlan', '')), e.emp_id as 'EmpId' ,pe.name AS 'Goal Plan Name' ,p.id ,(select top 1 (g.statusid) as 'Status' from goals g inner join goalassignments ga ON ga.goalid = g.id AND g.typeid IN (1,3,5) where ga.planid = p.id) from plans p inner join periods (nolock) AS pe on pe.id = p.periodid inner join vgr_emp (nolock) AS e on p.empid = e.emp_id mysql flow control

Categories : Sql Server

How can I change this SELECT statement into an UPDATE statement?
The basic syntax for updating via a JOIN in MySQL would look like this: UPDATE xxx_orders AS Orders LEFT OUTER JOIN xxx_items AS Items ON Orders.OrderNumber = Items.OrderNumber SET Orders.CancelledReason = 'Expired' WHERE DATEDIFF(NOW(), OrderDate) >= 14 AND Orders.Product = 'HOUSEHOLD' AND STATUS = 'BOOKING' AND Completed = 1 AND Items.Id IS NULL Edit: SET comes before WHERE

Categories : Mysql

php switch statement using text box/drop down box
$_POST is an array. It is NOT something you can compare against strings. PHP will convert the array to the literal word Array. Since you don't have a case with that word, you get no matches at all. Form values are submitted as elements of the $_POST array. You should be doing switch($_POST['cars']) { ... } instead

Categories : PHP

Selenium Webdriver with Java: How to select a random birth month and a random country from drop-down select options menu
You can place the labels within an array an then select a random element from it, by using the java.util.Random class. Then, when you gen a random name of a country, you can pass it to the Select object. String[] countriesArray = {"Japan", "Germany", "Australia", "Thailand"}; String randomLabel = countriesArray[new Random().nextInt(countriesArray.length)]; Select user_country = new Select (driver.findElement(By.id("user_country_id"))); user_country.selectByVisibleText(randomLabel);

Categories : Java

how to mysql_fetch_assoc for two select statement which is given in OR operator to select form either tables
You can try something like below. This way, all rows whether coming from table1 or table2 can be accessed using same key in array obtained from mysql_fetch_assoc. select name1 as name,email1 as email, mobile1 as mobile FROM table1 WHERE id=1 UNION ALL select name2 as name,email2 as email, '' as mobile FROM table2 WHERE id=1 Demo http://sqlfiddle.com/#!2/9d81c/1

Categories : PHP

need to show alert when i scroll down a certain div in html
You can trigger an event from your script after you have made the div visible using the .trigger function e.g //declare event to run when div is visible function isVisible(){ alert("hi"); } //hookup event $('#place').bind('isVisible', isVisible); //show div and trigger custom event in callback when div is visible $('#place').show('slow', function(){ $(this).trigger('isVisible'); });

Categories : Javascript

pgSQL, dynamic drop tables statement
You will need a dynamic query to be executed. To do that, you need to construct your query and call EXECUTE: DECLARE tmp TEXT; ... BEGIN ... FOR tmp IN SELECT names FROM Garbage LOOP EXECUTE 'DROP TABLE ' || quote_ident(tmp); END LOOP; ... Notice that I used quote_ident to escape the name properly, it is better and safer. But, if you created a table, let's say named MyTable but didn't quoted (double-quotes) it on creation time, PostgreSQL also store its name as mytable, so quote_ident('MyTable') will generate "MyTable" which doesn't exists, you should take care of it (e.g. always use the lowercase names or always quote your IDs).

Categories : SQL

select null within a select statement in SP when date is 01-01-1900
NullIF() is your friend here! DECLARE @d date = '1900-01-01'; SELECT @d As d , NullIf(@d, '1900-01-01') , NullIf(Current_Timestamp, '1900-01-01')

Categories : Sql Server

SELECT inside SELECT statement returns 0 count
Is this what you're looking for? select count(distinct concat(date_reserve, ' ', start_time)) as my_count, date_reserve,borrowerID,start_time,end_time from schedule where borrowerID = 'bobi' see it working in an sqlfiddle

Categories : Mysql

Inserting html in javascript alert/confirm
Jquery modal does the job for you. Below is the code which sets the value of the checkbox on close. http://jsfiddle.net/RSk4v/ $(function () { $("#dialog-confirm").dialog({ resizable: true, height: 150, modal: true, close: function () { $(this).find(':checked').each(function () { var name = $(this).attr('name'); $('input[name="' + name + '"]').val('checked '+name); }); }, buttons: { "Ok": function () { $(this).dialog("close"); }, Cancel: function () { $(this).dialog("close"); } } }); });

Categories : Javascript

Alert with a textarea content (HTML to JavaScript)
You should pass in this in your onfocus handler: onFocus="resetField(this);" Access it like: alert("It's entering the function."); alert(field.name); alert(field.value); Here's a demo: http://jsfiddle.net/RbUZr/

Categories : Javascript

how to add a logo or picture to the alert box using jquery and html
alert() won't render images :-( If you could add more detail about what you're trying to accomplish with the alert, we can come up with a suitable alternative. Since you're already using jQuery, this may interest you: http://jqueryui.com/dialog/

Categories : Javascript

Show element if has same html and if not make an alert saying "no results"
You just need to check the length of the results returned by the filter: // get matched elements var matches = $hidden.filter(function() { return $(this).text() == _selected; }); // show them, or alert if none if (matches.length > 0) matches.show(); else alert("There are no " + _selected + "'s"); See Fiddle

Categories : Javascript

html 5 web app cache download complete javascript alert?
In order to check when the cache download is complete, you are probably looking for the Cached event. It can be checked similar to the one you have above. window.applicationCache.addEventListener('cached', function() { // anything you need to do for success alert('I'm done!'); }, false );

Categories : Javascript

How to use alert message for Validation errors using Html.Validate
You can try extending the validation summary like this: public static class ValidationSummaryAlert { public static string ValidationSummaryWithAlert(this HtmlHelper ext) { if (!ext.ViewData.ModelState.IsValid) { var alertMessage = (from item in ext.ViewData.ModelState where item.Value.Errors.Any() && item.Key.Equals("Popup") select new { Message = item.Value.Errors[0].ErrorMessage, item.Key }).SingleOrDefault(); return string.Format( "<script language="javascript" type="text/javascript">$(function() {{alert('{0}')}});</script>", alertMessage); } return

Categories : Asp Net Mvc

alert the value of an HTML tag generated from javascript using - jquery "attr"
You can try to work from something like this: // Listen to click events on the button $("button").click(function(e) { // Find the input field by first finding the parenting tr, then find the input var input = $(this).parents("tr").find("input[type='text']"); alert(input.val()); }); In the callback function, this refers to the button, and you can find the parent tr by using .parents('tr'). After you have found the parent tr, you can find the input field. (This requires a certain structure of the HTML, so if you do major refactoring, the code might not work) Take a look at this JSFiddle to see it in action.

Categories : Javascript

Looking for Delete statement for this Select statement
Since you mentioned needing to delete from both tables you could do something like this: begin transaction declare @deleted table (MaterialNumber int) --whatever data type you need DELETE s output deleted.MaterialNumber into @deleted from [Stock Inventory] as s INNER JOIN customerservice as c ON s.MaterialNumber = c.Part DELETE c from customerservice as c join @deleted d on d.MaterialNumber = c.Part commit transaction

Categories : C#

SQL Translator (SQLFairy) - 'Invalid statement: Was expecting comment, or use, or set, or drop'
The solution for this would be that you export only your table defintions of your schema. The error in your example should btw. not occur on line five but on line six where the table gets locked for inserting data. As a solution dump your schema without the data, given your example above you can do the following to get a dump which is working with the fairy: mysqldump -u root -pmysql_root_password --no-data database_name > example.sql

Categories : Mysql

Select columns as select statement from other tables?
select table1.col1 as t1c1, table1.col2 as t1c2, table2.col1 as t2c1, table3.col1 as t3c1 from table1 join table2 join table3 note you will need to actually join table2 and table3... join statements like this won't work they don't have the ON part.

Categories : Mysql

Drop down select box with php
You might be better off using a foreach to put key and value in select as example below. <form action="" method="post"> <select id="jform_my_foreign_key" class="inputbox" name="jform[my_foreign_key]" size="1"> <option value="">- Select Order title -</option> <?php $data_for_select = array(13=>'00000013',12=>'00000012',9=>'0000009'); foreach($data_for_select as $k=>$v) { if($k==$_POST['jform']['my_foreign_key']) { echo "<option value="$k" selected="selected">$v</option>"; } else { echo "<option value="$k">$v</option>"; } } ?>

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.