Raised This Month: $ Target: $400
 0% 

html value to javascript


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 02-17-2009 , 07:50   html value to javascript
Reply With Quote #1

Hello i need some help and cant get it where ever i try....
here is my html code
Code:
<div class="wts">
<select name="WhatToSearch">
  <option value="videos">Videos</option>
  <option value="groups">groups</option>
</select>
</div>
and heres my javascript(i have different on another which is the one that works best ill add it later but for now i use this to get help to understand why)
Code:
if(select.WhatToSearch.value == videos){
function openWindow() { shell.Run("http://www.veoh.com/search/videos/q/" + escape(form.query.value)); return false; }
}
if(select.WhatToSearch.value == groups){
function openWindow() { shell.Run("http://www.veoh.com/search/groups/q/" + escape(form.query.value)); return false; }
}
i need help to get whats wrong in these codes i guess it has to do with the if function is outside the function but it doesnt work anyways so can someone help me write a working if function for this?
im not so good with such codes but i want to learn

edit

here is the one i have now
Code:
<!--
(c) by Micke1101
This is my veoh vista gadget
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Veoh video search</title>
<style type="text/css">
body {
    margin: 0;
    width: 135px;
    height: 135px;
    background-image: url(background.gif);
    background-repeat: no-repeat;
}
.search {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 9px;
    width: 100px;
    height: 18px;
    margin-top: 35px;
    margin-left: 17px;
    border: 1px solid #000000;
}
.layer {
    position: absolute;
    margin-top: 6px;
    margin-left: 11px;
    height: 30px;
    width: 110px;
    cursor: hand;
    cursor: pointer;
    background-image: url(blank.gif);
}
.wts{
    margin-top: -20px;
    margin-left: 30px;
}
.dropdowner{    /* Styling question */
    /* Start layout CSS */
    color:#FFF;
    font-size:0.9em;
    background: transparent;
    width:430px;
    margin-bottom:2px;
    margin-top: 0px;
    padding-left:2px;
    background-repeat:no-repeat;
    background-position:top right;    
    height:20px;
    
    /* End layout CSS */
    
    overflow:hidden;
    cursor:pointer;
}
.dropdowner_content{    /* Parent box of slide down content */
    /* Start layout CSS */
    border:1px solid #317082;
    background: transparent;
    width:400px;
    
    /* End layout CSS */
    
    visibility:hidden;
    height:0px;
    overflow:hidden;
    position:relative;

}
.dropdowner_content_content{    /* Content that is slided down */
    padding:1px;
    font-size:0.9em;    
    position:relative;
}

a{
color: white;
}
img {border: none;}
</style>
<script language="JavaScript" type="text/javascript">
var shell = new ActiveXObject('WScript.Shell');    

function openWindow(form) {
if (form.WhatToSearch.options[form.WhatToSearch.selectedIndex].value=='videos'){
shell.Run("http://www.veoh.com/search/videos/q/" + escape(form.query.value)); return false; 
} else {
shell.Run("http://www.veoh.com/search/groups/q/" + escape(form.query.value)); return false; 
}
}
function logoClick() { shell.Run("http://www.veoh.com"); return false; } 
</script>
<script type="text/javascript">
var dhtmlgoodies_slideSpeed = 10;    // Higher value = faster
var dhtmlgoodies_timer = 10;    // Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{
    if(dhtmlgoodies_slideInProgress)return;
    dhtmlgoodies_slideInProgress = true;
    if(!inputId)inputId = this.id;
    inputId = inputId + '';
    var numericId = inputId.replace(/[^0-9]/g,'');
    var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

    objectIdToSlideDown = false;
    
    if(!answerDiv.style.display || answerDiv.style.display=='none'){        
        if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){            
            objectIdToSlideDown = numericId;
            slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
        }else{
            
            answerDiv.style.display='block';
            answerDiv.style.visibility = 'visible';
            
            slideContent(numericId,dhtmlgoodies_slideSpeed);
        }
    }else{
        slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
        dhtmlgoodies_activeId = false;
    }    
}

function slideContent(inputId,direction)
{
    
    var obj =document.getElementById('dhtmlgoodies_a' + inputId);
    var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
    height = obj.clientHeight;
    if(height==0)height = obj.offsetHeight;
    height = height + direction;
    rerunFunction = true;
    if(height>contentObj.offsetHeight){
        height = contentObj.offsetHeight;
        rerunFunction = false;
    }
    if(height<=1){
        height = 1;
        rerunFunction = false;
    }

    obj.style.height = height + 'px';
    var topPos = height - contentObj.offsetHeight;
    if(topPos>0)topPos=0;
    contentObj.style.top = topPos + 'px';
    if(rerunFunction){
        setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
    }else{
        if(height<=1){
            obj.style.display='none'; 
            if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
                document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
                document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
                slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);                
            }else{
                dhtmlgoodies_slideInProgress = false;
            }
        }else{
            dhtmlgoodies_activeId = inputId;
            dhtmlgoodies_slideInProgress = false;
        }
    }
}



function initShowHideDivs()
{
    var divs = document.getElementsByTagName('DIV');
    var divCounter = 1;
    for(var no=0;no<divs.length;no++){
        if(divs[no].className=='dropdowner'){
            divs[no].onclick = showHideContent;
            divs[no].id = 'dhtmlgoodies_q'+divCounter;
            var answer = divs[no].nextSibling;
            while(answer && answer.tagName!='DIV'){
                answer = answer.nextSibling;
            }
            answer.id = 'dhtmlgoodies_a'+divCounter;    
            contentDiv = answer.getElementsByTagName('DIV')[0];
            contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';     
            contentDiv.className='dropdowner_content_content';
            contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
            answer.style.display='none';
            answer.style.height='1px';
            divCounter++;
        }        
    }    
}
window.onload = initShowHideDivs;
</script>
</head>
<body>
<div class="layer" onmousedown="return logoClick(this)";></div>
<form onsubmit="return openWindow(this)" action="" id="form"><input name="query" type="text" class="search" this.focus();" /></form>
<div class="wts">
<select name="WhatToSearch">
  <option value="videos">Videos</option>
  <option value="groups">groups</option>
</select>
</div>
<div class="dropdowner">Links</div>
<div class="dropdowner_content">
    <div>
        <a href="http://www.veoh.com/myprofile"><img src="images/profile.png" title="Profile"/></a>
        <a href="http://forums.veoh.com/forum"><img src="images/forum.png" title="Forum"/></a>
    </div>
</div>
</body>
</html>
also added it as its now

(though its a little different from how it should be its also here as a demo)
Attached Files
File Type: zip veoh.zip (12.8 KB, 93 views)

Last edited by micke1101; 02-17-2009 at 12:38.
micke1101 is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 02-17-2009 , 17:29   Re: html value to javascript
Reply With Quote #2

In your JavaScript why do you have TWO closing brackets after you perform the switch; statement?

You only need one.

Also, this doesn't belong here, this belongs in the Scripting Help. I am requesting a move :]
BOYSplayCS is offline
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 02-18-2009 , 01:55   Re: html value to javascript
Reply With Quote #3

Since this isnt amxx and the scripting help forum is for amxx this is the only place here it belongs
the second bracket is for the function the "switch" is in a function which needs a bracket to close
micke1101 is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 02-18-2009 , 11:00   Re: html value to javascript
Reply With Quote #4

The Scripting Help is for all kinds of coding help I've searched and found non-AMXX codes in there.

And, well an error could be you have a function outside of another which go together. Without an error log, there's not much I can do.

what errors are you getting?

Last edited by BOYSplayCS; 02-18-2009 at 11:27.
BOYSplayCS is offline
TeddyDesTodes
Senior Member
Join Date: Oct 2008
Location: 10.25.15.210
Old 02-18-2009 , 11:45   Re: html value to javascript
Reply With Quote #5

well ive tested it and firebug shows following:

Code:
ActiveXObject is not defined
(?)()blubb.html (Linie 83)

var shell = new ActiveXObject('WScript.Shell');
first : what are u trying to do?
second:
Code:
if(select.WhatToSearch.value == videos){
function openWindow() { shell.Run("http://www.veoh.com/search/videos/q/" + escape(form.query.value)); return false; }
}
if(select.WhatToSearch.value == groups){
function openWindow() { shell.Run("http://www.veoh.com/search/groups/q/" + escape(form.query.value)); return false; }
}
if u are declaring a function u still have to call it
or u have to do it like that:

Code:
function openWindow()
{
if(select.WhatToSearch.value == videos)
{
  shell.Run("http://www.veoh.com/search/groups/q/" + escape(form.query.value));
  return false;
}else if(select.WhatToSearch.value == groups){
  shell.Run("http://www.veoh.com/search/videos/q/" + escape(form.query.value));
  return false;

}
}
third : why the hell using windows scripting host??
PS: damn i hate this editor i want code block not quote...
__________________
TeddyDesTodes is offline
Send a message via ICQ to TeddyDesTodes
micke1101
Veteran Member
Join Date: Jan 2008
Location: Banned-town
Old 02-18-2009 , 12:07   Re: html value to javascript
Reply With Quote #6

The function is cald
Code:
<form onsubmit="return openWindow(this)" action="" id="form"><input name="query" type="text" class="search" this.focus();" /></form>
and the third i dont get

and this code crashes:
Code:
function openWindow()
{
if(select.WhatToSearch.value == videos)
{
  shell.Run("http://www.veoh.com/search/groups/q/" + escape(form.query.value));
  return false;
}else if(select.WhatToSearch.value == groups){
  shell.Run("http://www.veoh.com/search/videos/q/" + escape(form.query.value));
  return false;

}
}

Last edited by micke1101; 02-18-2009 at 12:15.
micke1101 is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 02-18-2009 , 16:52   Re: html value to javascript
Reply With Quote #7

Why are you returning false? That is not needed. I have tested and it runs fine without returning FALSE.

Last edited by BOYSplayCS; 02-18-2009 at 16:56.
BOYSplayCS is offline
TeddyDesTodes
Senior Member
Join Date: Oct 2008
Location: 10.25.15.210
Old 02-18-2009 , 17:40   Re: html value to javascript
Reply With Quote #8

just copied code
__________________
TeddyDesTodes is offline
Send a message via ICQ to TeddyDesTodes
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 02-18-2009 , 17:40   Re: html value to javascript
Reply With Quote #9

What?
BOYSplayCS is offline
TeddyDesTodes
Senior Member
Join Date: Oct 2008
Location: 10.25.15.210
Old 02-18-2009 , 18:10   Re: html value to javascript
Reply With Quote #10

nvm
__________________
TeddyDesTodes is offline
Send a message via ICQ to TeddyDesTodes
Reply



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

Forum Jump


All times are GMT -4. The time now is 02:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode