...

View Full Version : exact first word problem



coolumanga
06-29-2012, 07:26 AM
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

Philip M
06-29-2012, 07:51 AM
<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

coolumanga
06-29-2012, 08:38 AM
<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

Philip M
06-29-2012, 08:46 AM
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


var v1 = "UK00GEL GEL VERR";
var v2 = v1.split(" ");
alert (v2[0] + " " + v2[1] + " " + v2[2])



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum