[HTML/Javascript] URL, Concatenation and Variables. Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
4 posters

    [HTML/Javascript] URL, Concatenation and Variables.

    avatar
    -AusKinetic-
    Forumember


    Posts : 29
    Reputation : 0
    Language : Australia

    Solved [HTML/Javascript] URL, Concatenation and Variables.

    Post by -AusKinetic- Wed 30 Mar 2011 - 10:02

    Hi, i'm not sure if this is the right forum, but it looks the best to post this in.
    I'm trying to make a widget that incorporates this code, but this is the first time i am using HTML/Javascript, i have knowledge of basic programming and i'm not use to the syntax of these two languages.

    Here is my code:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function go()
    {
    var searchtype = document.cblsearch.searchtype;
    var searchname = document.cblsearch.searchname;
    var searchurl = "http://"+searchtype+".thecbl.net/"+searchname+".html";

    searchtype = document.cblsearch.searchtype;
    searchname = document.cblsearch.searchname;
    searchurl = "http://"+searchtype+".thecbl.net/"+searchname+".html";

    window.location="searchurl";
    }
    </script>
    </head>

    <body>
    <FORM NAME="cblsearch">
    <br>
    <select name="searchtype" size="1">
      <option value="player">Player</option>
      <option value="clan">Clan</option>
    </select>
    &nbsp<input type="text" name="searchname" size="15">
    </br>
    <br><INPUT TYPE="button" VALUE="Search" onclick="go()"></br>
    </FORM>
    </body>
    </html>

    Can someone fix it up, i want it to get data from the combo and textbox then insert it into a url, example: http:// [data from combobox here] .thecbl.net/ [data from textbox here] /, then go to that url.

    Keep in mind i want this in a widget, if possible, so i can display it on my clan page.
    avatar
    brenda
    Forumember


    Female Posts : 55
    Reputation : 0
    Language : english
    Location : Glasgow

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by brenda Wed 30 Mar 2011 - 23:55

    You would need a database to do this, searching for names ect.
    We dont have access to forum database.
    The only way i think you could do this for example. Build a wiget with notepad or wordpad with a list of name built iin which would pull out the names.
    You would have to use a program lang VB you should know what i mean if you have programing exprence.
    Good luck with this one.
    But even then it might not work on the forum.
    Brenda
    avatar
    -AusKinetic-
    Forumember


    Posts : 29
    Reputation : 0
    Language : Australia

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by -AusKinetic- Thu 31 Mar 2011 - 10:16

    I can easily make this in VB.
    But i want a widget, and i don't think you understand what i want.

    It will access another site, i just need to be able to modify the site URL, using user input from a textbox and combobox.
    avatar
    brenda
    Forumember


    Female Posts : 55
    Reputation : 0
    Language : english
    Location : Glasgow

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by brenda Thu 31 Mar 2011 - 23:30

    So the combobox when clicking on it will redirect you to a website.
    Also if you type a entry it will also take you to a site. is that what you mean.
    Brenda
    avatar
    -AusKinetic-
    Forumember


    Posts : 29
    Reputation : 0
    Language : Australia

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by -AusKinetic- Fri 1 Apr 2011 - 4:09

    the combobox has 2 options so it is either on one of them, the textbox will have anything.

    then when a button is clicked it will go to a url. that url is modified from the data from the combobox and textbox.

    example:

    combobox [ player]
    textbox [playername]

    so the button is clicked

    it will go to url

    http://[player].thecbl.net/[playername]/

    like that.
    avatar
    -AusKinetic-
    Forumember


    Posts : 29
    Reputation : 0
    Language : Australia

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by -AusKinetic- Fri 1 Apr 2011 - 12:28

    bump!
    avatar
    Quozzo
    New Member


    Posts : 2
    Reputation : 10
    Language : English

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by Quozzo Sat 2 Apr 2011 - 0:41

    These use jQuery right?
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function go()
    {
    window.location="http://"+$('select[name=searchtype]').val()+".thecbl.net/"+$('input[name=searchname]').val()+"/";
    }
    </script>
    </head>

    <body>
    <FORM NAME="cblsearch">
    <br />
    <select name="searchtype" size="1">
      <option value="player">Player</option>
      <option value="clan">Clan</option>
    </select>
    &nbsp<input type="text" name="searchname" size="15">
    <br />
    <br /><INPUT TYPE="button" VALUE="Search" onclick="go()"><br />
    </FORM>
    </body>
    </html>

    the HTML for a line break is either <br> or <br/> for XHTML its <br /> but either way its definitely not what you were doing </br>


    Last edited by Quozzo on Sat 2 Apr 2011 - 0:46; edited 1 time in total (Reason for editing : HTML was messsssy!)
    avatar
    -AusKinetic-
    Forumember


    Posts : 29
    Reputation : 0
    Language : Australia

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by -AusKinetic- Sat 2 Apr 2011 - 12:11

    it doesn't seem to work.
    i tried to test it by making a html file and when i click search nothing happens.
    avatar
    Quozzo
    New Member


    Posts : 2
    Reputation : 10
    Language : English

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by Quozzo Sat 2 Apr 2011 - 15:16

    You probably havn't got jQuery on the board, try this instead
    Code:
    function go()
    {
    var option=document.cblsearch.searchtype.options[document.cblsearch.searchtype.selectedIndex].value
    window.location= "http://" + option + ".thecbl.net/" + document.cblsearch.searchname.value
    }
    avatar
    -AusKinetic-
    Forumember


    Posts : 29
    Reputation : 0
    Language : Australia

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by -AusKinetic- Sun 3 Apr 2011 - 3:49

    It works perfectly!
    Thanks Quozzo!
    Sanket
    Sanket
    ForumGuru


    Male Posts : 48766
    Reputation : 2830
    Language : English
    Location : Mumbai

    Solved Re: [HTML/Javascript] URL, Concatenation and Variables.

    Post by Sanket Sun 3 Apr 2011 - 6:31

    Since this thread appears to be solved, I will lock this thread and mark it as solved.
    [HTML/Javascript] URL, Concatenation and Variables. 2j4t5a8

    Sanket Smile