50% OFF!!!

Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Monday, July 11, 2022

JQuery serialize on form is EMPTY (ajax/post/get)

 Hi All,


I had several times a problem, that the collected data by jQuery API's serialize() or serializeArray() was empty, although the inputs were not empty.

Follow these checkups to by pass the problem.

1] when the input don't name attribute the result will be empty.

<form id="form1">
        <input type="text" value="test value">
        <button>submit</button>
</form>
//$('#form1').serialize()  ==> "" (empty)
 
 
SOLUTION:
<form id="form1">
        <input type="text" value="test value" value="ANYNAME">
        <button>submit</button>
</form>
//$('#form1').serialize()  ==> "ANYNAME=test+value" 
 

Thursday, December 22, 2016

c# | WebBrowser control - programmatically select item on html `select`

Hi There,

As many times, we need to interact with the C# (.Net) Webbrowser Control, 
it is useful to be able to interact and programmatically change the selected item 
on an HTML select control.

I don't know, why it is hard to find this easy solution, but the code is as follow:


HtmlElementCollection col = webBrowser1.Document.GetElementsByTagName("select") 
foreach (HtmlElement heItem in col) 
{ 
  if (heItem.GetAttribute("className").Contains("exampleClassName") == true) 
  { 
    heItem.SetAttribute("selectedIndex", "3"); // select value at #3
    break; // incase of needed... 
  } 
}  


And finally, just easy as u code...


If you need change by value and not by index,
I assume you can check the values of the select control (sometimes called: dropdown),
and once you find the correct index of the desired value,
use the code above.



MDB-BLOG :)

Thursday, June 18, 2009

Working with sql xml | Sql server


Here is a code for manipulating XML object under SQL Server.
This code allow to recieve attribute and note contents.
Best for xml manipulations.

--Under this configuration:
DECLARE @xml XML
SET @xml = '<root><a><b id="456"></b><c>world...</c></a></root>'


--Get attribute's content from xml field:
SELECT @xml.value('(//root/a/b/@id)[1]','int') AS 'Attribute Content'


--Get node's content from xml field:
SELECT @xml.value('(//root/a/c)[1]','nvarchar(MAX)') AS 'Node Content'