Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
A simple js function not working...
Old 04-14-2010, 06:21 AM A simple js function not working...
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi,

Here's a simple js function I am running but its just not working.....Please help and let me know where I mistook..

code is here:

HTML Code:
 <div id="cat_comp" class="search_label display">Search By
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="comp_cat" onclick="javascript: changesrchtype();" class="radiobtn" id="company" />
                Company / Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="comp_cat" class="radiobtn" id="category" checked="true" tabindex="1" />
                Product / Services
        </div>
Quote:
function changesrchtype()
{
var a = document.getElementById('company').checked;

if(a==true)
{
alert("I am Working. (Company)");

}
else
{
alert("I am Working. (product)");
}
}
Thanks in Advance!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-14-2010, 08:28 AM Re: A simple js function not working...
Extreme Talker

Posts: 177
Trades: 0
I copied your code exactly and it's working fine. Try doing an
Code:
alert(a);
before the if statement. Also, open up the error console in the browser to see if it throws anything at you.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 04-14-2010, 09:05 AM Re: A simple js function not working...
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
thanks..so...much kbfr.....

Here's what I've updated.....

please help.....

Quote:
function changesrch()
{
var a = document.userinfo.searchstatus.value;
var str = "<script type='text/javascript' src='script/ajax.js'></script> <script type='text/javascript' src='script/ajax-dynamic-list.js'></script><input id='get_searchword' name='get_searchword' autocomplete='off' onKeyUp='ajax_showOptions(this,'getkeywordsByLette rs',event)' class='input_search'/>";

if(a=="company")
{
alert("I am Inside company.");
document.getElementById('searchAJAXA').innerHTML= str;
}
else
{
alert("I am Inside Keyword.");
}

}
</script>
Your any help would be appreciated.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Old 04-15-2010, 01:32 AM Re: A simple js function not working...
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi guys,

I am trying to call 2 different scripts by using javascript........innerHTML.....It seems not working....funtion is working and changing value though.

Here's what I am trying:

Quote:

<script language="javascript" type="text/javascript">
function changesrch()
{
var a = document.userinfo.searchstatus.value;

if(a=="company")
{
alert("I am Inside company.");
//var c = ";
var str="<script type='text/javascript' src='script/ajax.js' DEFER>";
document.getElementById('searchAJAXA').innerHTML=s tr;
var stv="<script type='text/javascript' src='script/ajax-dynamic-list.js' defer='defer'>";
document.getElementById('search2AJAXA').innerHTML= stv;
}
else
{
alert("I am Inside Keyword.");
var str1="<script type='text/javascript' src='scripts/ajax.js' DEFER>";
document.getElementById('searchAJAXA').innerHTML=s tr1;
var str2="<script type='text/javascript' src='scripts/ajax-dynamic-list.js' defer='defer'>";
document.getElementById('search2AJAXA').innerHTML= str2;
}

}
</script>


<!--*********************************************-->

<select name="searchstatus" onChange="javascript: changesrch();" id="searchstatus" tabindex="1">
<option value="">Select One</option>
<option value="company">company</option>
<option value="Product">Product</option>
</select>


<div id="searchAJAXA">
<script type="text/javascript" src="scripts/ajax.js" defer></script>
</div>
<div id="search2AJAXA">
<script type="text/javascript" src="scripts/ajax-dynamic-list.js" defer></script>
</div>
<input id="get_searchword" name="get_searchword" tabindex="3" autocomplete="off" onKeyUp="ajax_showOptions(this,'getkeywordsByLette rs',event)" class="input_search" />

Your help would be appreciated.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to A simple js function not working...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.83119 seconds with 12 queries