The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

[HTML/Javascript] URL, Concatenation and Variables.

View previous topic View next topic Go down

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

Post by -AusKinetic- on 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.

-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by brenda on 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

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- on 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.

-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by brenda on 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

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- on 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.

-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

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

bump!

-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by Quozzo on 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!)

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- on 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.

-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

Post by Quozzo on 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
}

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- on April 3rd 2011, 3:49 am

It works perfectly!
Thanks Quozzo!

-AusKinetic-
Forumember

Posts : 29
Reputation : 0
Language : Australia

Back to top Go down

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

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

Since this thread appears to be solved, I will lock this thread and mark it as solved.


Sanket Smile


Sanket
ForumGuru

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

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


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