INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to get value text in HTML page

How to get value text in HTML page

(OP)
Hello everybody .
I have read this reference
http://msdn.microsoft.com/en-us/library/aa752127%2...
http://msdn.microsoft.com/en-us/library/aa768277%2...
http://msdn.microsoft.com/en-us/library/aa752574%2...
Now , I want to check user input text . If the user enters "http://google.com". After "DISPID_BEFORENAVIGATE2" of Internet Explorer Web Browser loaded successfully. it checks if the same "http://google.com" then return "about: blank"
This is my form HTML

CODE --> HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
	<label>Website ABC</label>
	<br>
	<input type="text" name="txt_url" value="http://google.com" size="50">
	<br>
	<textarea name="txt_url2" cols="50" rows="2">http://msdn.com</textarea>
	<br>
	<input type="checkbox" name="chk_male" value="Male" checked>
	<br>
	<input type="text" name="T1" size="20" value="http://yahoo.com">
	<input type="submit" value="Submit" name="B1">
	<input type="reset" value="Reset" name="B2">
	<br>
	<input type="submit" name="Ok" value="ok_click">
	<input type="reset" value="cancel_click" name="Cancel">
</form>
</body>
</html> 
Note : In this HTML have to three text input
And this is event code

CODE --> C++

STDMETHODIMP ABCtest::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pvarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)   
{   
    USES_CONVERSION; // This macro should be called when using ATL string conversion
					//	macros to avoid compile errors (here we are using OLE2T)
	
    if(dispidMember == DISPID_BEFORENAVIGATE2)   
    {   
       BSTR bstrName;
		HRESULT hRes=m_spWebBrowser2->get_Name(&bstrName);
		//bstrName.ToUpper();
		
		if(SUCCEEDED(hRes) && bstrName == "INPUT")   
		{  
			BSTR bstrType;   
			HRESULT hRes = m_spWebBrowser2->get_Type(&bstrType);   
			//bstrType.ToLower(); 
		
			if(SUCCEEDED(hRes) && bstrType == "text")   
			{   
				BSTR bstrValue;   
				HRESULT hRes = m_spWebBrowser2->get_value(&bstrValue);   
				
				if(SUCCEEDED(hRes))  
				{   
					if(bstrValue.Length()>0)   
					{   
						// Convert the text from Unicode to ANSI
						LPTSTR value_text = new TCHAR[SysStringLen(bstrValue)];   
						lstrcpy(value_text, OLE2T(bstrValue));  
					}  				
				}
			}
		}
	
		if(strcmp("http://google.com",(const char*)value_text) == 0) 
		{		
			VARIANT vFlags = {0},vTargetFrameName = {0};
			// Instead of about:blank, you can redirect http://yahoo.com
			m_spWebBrowser2->Navigate(SysAllocString(L"about:blank"),&vFlags,&vTargetFrameName,NULL,NULL);
			m_spWebBrowser2->put_Visible(VARIANT_TRUE);
			return S_FALSE;
		}
		return S_OK;
    }   
    else if(dispidMember == DISPID_NAVIGATECOMPLETE2)  // This checking is done to avoid post-navigation
    {                                           		// loading of a page.
		BSTR bstrName;
		HRESULT hRes=m_spWebBrowser2->get_Name(&bstrName);
		//bstrName.ToUpper();
		
		if(SUCCEEDED(hRes) && bstrName == "INPUT")   
		{  
			BSTR bstrType;   
			HRESULT hRes = m_spWebBrowser2->get_Type(&bstrType);   
			//bstrType.ToLower(); 
		
			if(SUCCEEDED(hRes) && bstrType == "text")   
			{   
				BSTR bstrValue;   
				HRESULT hRes = m_spWebBrowser2->get_value(&bstrValue);   
				
				if(SUCCEEDED(hRes))  
				{   
					if(bstrValue.Length()>0)   
					{   
						LPTSTR value_text = new TCHAR[SysStringLen(bstrValue)];   
						lstrcpy(value_text, OLE2T(bstrValue)); 
					}  				
				}
			}
		}	
	
        if(strcmp("http://google.com/",(const char *)value_text) == 0)   
        {   
            VARIANT vFlags = {0},vTargetFrameName = {0};   
            m_spWebBrowser2->Navigate(SysAllocString(L"about:blank"),&vFlags,&vTargetFrameName,NULL,NULL);   
            m_spWebBrowser2->put_Visible(VARIANT_TRUE);   
        }   
        return S_OK;   
    }   
    return S_FALSE;   
} 

RE: How to get value text in HTML page

(OP)
Hi for all .
Do you understand about it ?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close