Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-29-2012, 07:26 AM   PM User | #1
coolumanga
Regular Coder

 
Join Date: Sep 2010
Posts: 106
Thanks: 6
Thanked 0 Times in 0 Posts
coolumanga is an unknown quantity at this point
exact first word problem

hi i have this

function getComboA(sel) {
var v1 = sel.options[sel.selectedIndex].value;

in hear i `m getting v1 as

v1=UK00GEL GEL

but i want to get to v1=UK00GEL



document.getElementById('b').value =v1;

}

... how do i do this to get the value only the first word
coolumanga is offline   Reply With Quote
Old 06-29-2012, 07:51 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,042
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Code:
<script type = "text/javascript">
var v1 = "UK00GEL GEL";
v1 = v1.replace(/\s\w+/,"");
alert (v1);
</script>
Instead of
var v1 = sel.options[sel.selectedIndex].value;
you can simply use
var v1 = sel.value;

A child of five would understand this. Send someone to fetch a child of five.
Groucho Marx
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 06-29-2012, 08:38 AM   PM User | #3
coolumanga
Regular Coder

 
Join Date: Sep 2010
Posts: 106
Thanks: 6
Thanked 0 Times in 0 Posts
coolumanga is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
Code:
<script type = "text/javascript">
var v1 = "UK00GEL GEL";
v1 = v1.replace(/\s\w+/,"");
alert (v1);
</script>
Instead of
var v1 = sel.options[sel.selectedIndex].value;
you can simply use
var v1 = sel.value;

A child of five would understand this. Send someone to fetch a child of five.
Groucho Marx
hi thankz for the reply ...its work for me

another thing can i have

var v1 = "UK00GEL GEL VERR";

exacting the VERR word OR GEL word from this

plzz help me for this
coolumanga is offline   Reply With Quote
Old 06-29-2012, 08:46 AM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,042
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by coolumanga View Post
hi thankz for the reply ...its work for me

another thing can i have

var v1 = "UK00GEL GEL VERR";

exacting the VERR word OR GEL word from this

plzz help me for this
Code:
var v1 = "UK00GEL GEL VERR";
var v2 = v1.split(" ");
alert (v2[0] +  "   " + v2[1] +  "   " + v2[2])
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 +1. The time now is 05:27 PM.


Advertisement
Log in to turn off these ads.