View the DQSD CVS repository here:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/
Update of /cvsroot/dqsd/dqsd/src/DQSDSearchWiz
In directory usw-pr-cvs1:/tmp/cvs-serv5076/src/DQSDSearchWiz
Modified Files:
DQSDWizardDlg.cpp
Added Files:
test.htm
Log Message:
Fix radio buttons
--- NEW FILE: test.htm ---
<html>
<head>
</head>
<body>
<form name="form1" method="GET" action="">
<p><input type="text" name="textfield"></p>
<p><input type="checkbox" name="checkbox1" value="ON" checked></p>
<p><input type="checkbox" name="checkbox2" value="ON"></p>
<p><select name="select1">
<option value="op1">Option 1</option>
<option value="op2" selected>Option 2</option>
</select></p>
<p>
<input type="radio" name="radio1" value="option1" checked>
<input type="radio" name="radio1" value="option2">
<input type="radio" name="radio1" value="option3"></p>
<input type="submit">
</form>
</body>
</html>
Index: DQSDWizardDlg.cpp
===================================================================
RCS file: /cvsroot/dqsd/dqsd/src/DQSDSearchWiz/DQSDWizardDlg.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** DQSDWizardDlg.cpp 9 Aug 2002 22:58:25 -0000 1.17
--- DQSDWizardDlg.cpp 10 Aug 2002 06:37:19 -0000 1.18
***************
*** 33,36 ****
--- 33,47 ----
}
+ struct CRadioButtonInfo
+ {
+ CRadioButtonInfo( const string& rstrValue, BOOL bActiveElement = FALSE, BOOL
+bChecked = FALSE )
+ : m_strValue( rstrValue )
+ , m_bActiveElement( bActiveElement )
+ , m_bChecked( bChecked )
+ { }
+ string m_strValue;
+ BOOL m_bActiveElement;
+ BOOL m_bChecked;
+ };
/////////////////////////////////////////////////////////////////////////////
***************
*** 515,519 ****
{
// Map a radio button to its values
! // map< string, string > mapRadioButtons;
rstrFormScript += _T("\r\n\r\n // FORM variables
for ") + strFormName;
--- 526,532 ----
{
// Map a radio button to its values
! typedef vector< CRadioButtonInfo > RadioButtonValues_t;
! typedef map< string, RadioButtonValues_t >
RadioButtonMap_t;
! RadioButtonMap_t mapRadioButtons;
rstrFormScript += _T("\r\n\r\n // FORM variables
for ") + strFormName;
***************
*** 542,547 ****
// Ignore INPUT type=submit
_variant_t varInputType;
! if ( ( SUCCEEDED(
spElement->getAttribute( _bstr_t( _T("type") ), 0, &varInputType ) ) &&
varInputType.bstrVal ) && !wcsicmp( L"submit", varInputType.bstrVal ) )
continue;
--- 555,565 ----
// Ignore INPUT type=submit
+ string strInputType = _T("");
_variant_t varInputType;
! if ( SUCCEEDED(
spElement->getAttribute( _bstr_t( _T("type") ), 0, &varInputType ) ) )
! {
! strInputType = W2T(
varInputType.bstrVal );
! }
! if ( !_tcsicmp( _T("submit"),
strInputType.c_str() ) )
continue;
***************
*** 551,590 ****
BOOL bActiveElement =
spElementUnk.IsEqualObject( spActiveElementUnk );
- if ( bActiveElement )
- {
- strFormXML += _T("\r\n
<COMMENT> The following field was active (i.e. had focus) when the search was
generated. </COMMENT>");
- }
! strFormXML += _T("\r\n <input
type=\"hidden\" name=\"") + strInputName + _T("\"");
- // Stick the value of the field in as
well for two reasons... some hidden fields are required
- // and the user can enter a string in
a visible field to see which field to use.
-
_variant_t varInputValue;
if ( SUCCEEDED(
spElement->getAttribute( _bstr_t( _T("value") ), 0, &varInputValue ) ) &&
varInputValue.bstrVal )
{
! strFormXML += _T(" value=\"")
+ EscapeXML( string( W2T( varInputValue.bstrVal ) ) ) + _T("\"");
! }
! else
! {
! strFormXML += _T("
value=\"\"");
}
! // map< string, string >::iterator
itFound;
! // if ( varInputType.bstrVal && !wcsicmp(
L"radio", varInputType.bstrVal ) )
! // {
! // itFound =
mapRadioButtons.find( W2T( varInputType.bstrVal ) );
! // if ( itFound !=
mapRadioButtons.end() )
! // {
! // string strCurrValues =
itFound->second;
! // mapRadioButtons[ W2T(
varInputType ) ] = strCurrentValues + _T(" ") + EscapeXML( string( W2T(
varInputValue.bstrVal ) ) );
! // }
! // }
! strFormXML += _T("/>");
// If there are any non-alpha
characters in the INPUT field name, the use different notation in the script
string strScriptInputName = _T(".") +
strInputName + _T(".value");
! if ( ( strInputName.find_first_not_of(
_T("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0 ) != string::npos ) ||
( !_tcsicmp(
strInputName.c_str(), _T("target") ) ) ||
( !_tcsicmp(
strInputName.c_str(), _T("submit") ) ) )
--- 569,613 ----
BOOL bActiveElement =
spElementUnk.IsEqualObject( spActiveElementUnk );
! // Get the value
_variant_t varInputValue;
+ string strInputValue = _T("");
if ( SUCCEEDED(
spElement->getAttribute( _bstr_t( _T("value") ), 0, &varInputValue ) ) &&
varInputValue.bstrVal )
{
! strInputValue = EscapeXML(
string( W2T( varInputValue.bstrVal ) ) );
}
! // Stick the value of the field in as
well for two reasons... some hidden fields are required
! // and the user can enter a string in
a visible field to see which field to use.
!
! if ( !_tcsicmp( _T("radio"),
strInputType.c_str() ) )
! {
! BOOL bChecked = FALSE;
! _variant_t varChecked;
! if ( SUCCEEDED(
spElement->getAttribute( _bstr_t( _T("checked") ), 0, &varChecked ) ) )
! {
! bChecked =
varChecked.boolVal;
! }
! RadioButtonMap_t::iterator
itFound = mapRadioButtons.find( strInputName );
! RadioButtonValues_t
radioValues;
! if ( itFound !=
mapRadioButtons.end() )
! {
!
itFound->second.push_back( CRadioButtonInfo( strInputValue, bActiveElement, bChecked )
);
! ATLTRACE( _T("%s =
%d\n"), strInputName.c_str(), itFound->second.size() );
! }
! else
! {
! radioValues.push_back(
CRadioButtonInfo( strInputValue, bActiveElement, bChecked ) );
!
mapRadioButtons.insert( RadioButtonMap_t::value_type( strInputName, radioValues ) );
! }
! continue;
! }
// If there are any non-alpha
characters in the INPUT field name, the use different notation in the script
+
string strScriptInputName = _T(".") +
strInputName + _T(".value");
! if ( ( strInputName.find_first_not_of(
_T("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"), 0 ) !=
string::npos ) ||
( !_tcsicmp(
strInputName.c_str(), _T("target") ) ) ||
( !_tcsicmp(
strInputName.c_str(), _T("submit") ) ) )
***************
*** 595,598 ****
--- 618,628 ----
if ( bActiveElement )
{
+ strFormXML += _T("\r\n
+<COMMENT> The following field was active (i.e. had focus) when the search was
+generated. </COMMENT>");
+ }
+
+ strFormXML += _T("\r\n <input
+type=\"hidden\" name=\"") + strInputName + _T("\" value=\"") + strInputValue + _T("\"
+/>");
+
+ if ( bActiveElement )
+ {
rstrFormScript += _T("\r\n"
"\r\n // The wizard assigned the search string to this form field value
because"
***************
*** 608,613 ****
if ( !_tcsicmp( W2T( bstrTagName ),
_T("SELECT") ) )
{
! strFormXML += _T("\r\n
<COMMENT> The input element above was a SELECT element with the following
options...");
! strFormXML += _T("\r\n
<select name=\"" + strInputName + "\">");
CComQIPtr< IHTMLSelectElement
> spSelect( spElement );
--- 638,644 ----
if ( !_tcsicmp( W2T( bstrTagName ),
_T("SELECT") ) )
{
! strFormXML += _T("\r\n
<COMMENT>"
!
"\r\n The input element above, \"") + strInputName + _T("\", was a SELECT
element with the following options..."
!
"\r\n <select name=\"" + strInputName + "\">");
CComQIPtr< IHTMLSelectElement
> spSelect( spElement );
***************
*** 642,651 ****
strFormXML += _T("\r\n
</select>"
"\r\n </COMMENT>");
! }
! }
::SysFreeString( bstrTagName );
}
! }
--- 673,729 ----
strFormXML += _T("\r\n
</select>"
"\r\n </COMMENT>");
!
! } // end-if SELECT
!
! } // end-if INPUT element had a 'name'
attribute
::SysFreeString( bstrTagName );
+
+ } // end-for each form element
+
+
+ // Append radio INPUT elements
+
+ if ( mapRadioButtons.size() > 0 )
+ {
+ RadioButtonMap_t::const_iterator itElements =
+mapRadioButtons.begin();
+ for ( ; itElements != mapRadioButtons.end();
+itElements++ )
+ {
+ string strRadioElement = _T("\r\n
+<input type=\"hidden\" name=\"") + itElements->first + _T("\" value=\"");
+ string strRadioValues = _T("\r\n
+<COMMENT>"
+
+ "\r\n The input element above, \"") + itElements->first + ("\"
+was a set of radio buttons with the following options...");
+
+ RadioButtonValues_t::const_iterator
+itValues = itElements->second.begin();
+ string strDelim = _T("\r\n ");
+ for ( ; itValues !=
+itElements->second.end(); itValues++ )
+ {
+ strRadioValues += strDelim +
+_T("\"") + itValues->m_strValue + _T("\"");
+ strDelim = _T(", ");
+ if ( itValues->m_bChecked )
+ {
+ strRadioElement +=
+itValues->m_strValue;
+ }
+ }
+
+ string strScriptInputName = _T(".") +
+itElements->first + _T(".value");
+ if ( (
+itElements->first.find_first_not_of(
+_T("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"), 0 ) !=
+string::npos ) ||
+ ( !_tcsicmp(
+itElements->first.c_str(), _T("target") ) ) ||
+ ( !_tcsicmp(
+itElements->first.c_str(), _T("submit") ) ) )
+ {
+ strScriptInputName = _T("[\"")
++ itElements->first + _T("\"].value");
+ }
+ rstrFormScript += _T("\r\n
+//document.") + strFormName + strScriptInputName + _T(" = \"\";");
+
+ strRadioElement += _T("\" />");
+
+ strRadioValues += _T("\r\n
+<COMMENT>");
+
+ strFormXML += strRadioElement;
+ strFormXML += strRadioValues;
+ }
}
!
!
! } // end-if able to get form element count
***************
*** 653,658 ****
++iSelectedForms;
! }
! }
if ( 0 == cForms )
--- 731,741 ----
++iSelectedForms;
!
! } // end-if this form was selected by user
!
! } // end-for each form
!
!
! // If there were no forms, then go ahead and create a template for one
if ( 0 == cForms )
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
DQSD-CVS mailing list
https://lists.sourceforge.net/lists/listinfo/dqsd-cvs
DQSD CVS repository:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/dqsd/