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.

[HTML/Javascript] URL, Concatenation and Variables.

4 posters

Go down

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

Post by -AusKinetic- March 30th 2011, 10:02 am

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
-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by brenda March 30th 2011, 11:55 pm

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
brenda
Forumember

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

http://cumbernaulddogwalks.forumakers.com

Back to top Go down

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

Post by -AusKinetic- March 31st 2011, 10:16 am

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
-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by brenda March 31st 2011, 11:30 pm

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
brenda
Forumember

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

http://cumbernaulddogwalks.forumakers.com

Back to top Go down

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

Post by -AusKinetic- April 1st 2011, 4:09 am

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

Back to top Go down

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

Post by -AusKinetic- April 1st 2011, 12:28 pm

bump!
avatar
-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by Quozzo April 2nd 2011, 12:41 am

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 April 2nd 2011, 12:46 am; edited 1 time in total (Reason for editing : HTML was messsssy!)
avatar
Quozzo
New Member

Posts : 2
Reputation : 10
Language : English

Back to top Go down

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

Post by -AusKinetic- April 2nd 2011, 12:11 pm

it doesn't seem to work.
i tried to test it by making a html file and when i click search nothing happens.
avatar
-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by Quozzo April 2nd 2011, 3:16 pm

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
Quozzo
New Member

Posts : 2
Reputation : 10
Language : English

Back to top Go down

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

Post by -AusKinetic- April 3rd 2011, 3:49 am

It works perfectly!
Thanks Quozzo!
avatar
-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by Sanket April 3rd 2011, 6:31 am

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

Sanket
Sanket
ForumGuru

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

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum